Question : loop through map in js
Answered by : alive-alligator-hxptq91pimki
const object = {'a': 1, 'b': 2, 'c' : 3};
for (const [key, value] of Object.entries(object)) { console.log(key, value);
}
Source : https://stackoverflow.com/questions/16507866/iterate-through-a-map-in-javascript/54550693 | Last Update : Tue, 14 Apr 20
Question : how to loop through a map in js
Answered by : breakable-baboon-md4fm5tl6l6b
var myMap = new Map();
myMap.set("0", "foo");
myMap.set(1, "bar");
myMap.set({}, "baz");
for (const [key, value] of Object.entries(myMap)) { console.log(key, value);
}
Source : | Last Update : Wed, 19 May 21
Question : map looping
Answered by : gorgeous-goosander-ukglqxuimwpl
showDetails(cards, id){ cards.map(function(card, index){ if(card.id==id){ console.log(card); return card; } })
}
Source : https://stackoverflow.com/questions/42462230/how-do-i-make-a-map-function-return-a-single-value-rather-than-an-array | Last Update : Fri, 21 Jan 22
Question : map loop
Answered by : francisco-pd1a9te0qvnn
function findLongestWordLength(str) { return Math.max(...str.split(" ").map(word => word.length))
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Source : | Last Update : Mon, 09 May 22