So I'm trying to compare the keys of two maps. The code below is syntactically valid; however, it returns false even though the keys of the two maps are similar. What could be the problem here?
const sc = new Map ();
sc.set ("item1",1)
sc.set ("item2",1)
sc.set ("item3",2)
sc.set ("item4",1) //ounce per serving //
const ing = new Map();
ing.set ("item1",1)
ing.set ("item2",1)
ing.set ("item3",2)
ing.set ("item4",1) //ounce per serving //
function compareMaps (map1,map2) {
if (ing.keys() == sc.keys() && (ing.size == sc.size)) {
return "true"
}
return "false"
}
compareMaps(ing, sc)