Answers for "how to loop through string in javascript with map"

4

loop through map in js

const object = {'a': 1, 'b': 2, 'c' : 3};
for (const [key, value] of Object.entries(object)) {
  console.log(key, value);
}
Posted by: Guest on April-07-2020
0

Javascript using .map() loop to loop through an array

// Durations are in minutes 
const tasks = [
  {
    'name'     : 'Write for Envato Tuts+',
    'duration' : 120
  },
  {
    'name'     : 'Work out',
    'duration' : 60
  },
  {
    'name'     : 'Procrastinate on Duolingo',
    'duration' : 240
  }
];
const task_names = tasks.map(function (task, index, array) {
    return task.name; 
});

console.log(task_names) // [ 'Write for Envato Tuts+', 'Work out', 'Procrastinate on Duolingo' ]
Posted by: Guest on January-22-2022

Code answers related to "how to loop through string in javascript with map"

Code answers related to "Javascript"

Browse Popular Code Answers by Language