I'm trying to create a map of objects to use by the following code:
var MARKED ={className: 'emoji', img:'⚐'} ;
var EMOJI_WONDER = {className: 'emoji', img: '🙄'};
var EMOJI_WIN = {className: 'emoji', img: '😁'};
var emoMap={};
emoMap[EMOJI_WONDER]=EMOJI_WONDER;
emoMap[MARKED]=MARKED;
emoMap[EMOJI_WIN]=EMOJI_WIN;
console.log(emoMap);
and i get object object. I've made a map before with the following code:
var str = 'this is a test la la la la lo';
var wordMap = countWordApperances(str);
console.log(str, 'got: ', wordMap);
function countWordApperances(txt) {
var wordCountMap = {};
var words = txt.split(' ');
for (var i = 0; i < words.length; i++) {
var currWord = words[i];
if (wordCountMap[currWord]) wordCountMap[currWord]++;
else wordCountMap[currWord] = 1;
}
return wordCountMap;
}
and i just can't tell why the top code won't set a map and the bottom code does.