Map.has() is true/false | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Map.has() is true/false

Why doesn’t this output true or false? Instead it returns 1 for true and I guess -1 for false. What is the determination for 1 or true as the output?

19th Jun 2019, 12:22 PM
RobertS
RobertS - avatar
3 Answers
+ 1
Looks to me like it is a boolean value :/
21st Jun 2019, 4:48 PM
Airree
Airree - avatar
0
If you would provide us your code, we might be able to help. Maybe you turned it into a number at some point, but we will never know
19th Jun 2019, 12:27 PM
Airree
Airree - avatar
0
I didnt put in code because this is directly from the lessons...I thought it would link back to it. Here is the code Im talking about: let map = new Map(); map.set('k1', 'v1').set('k2', 'v2'); console.log(map.get('k1')); // v1 console.log(map.has('k2')); // true for (let kv of map.entries()) console.log(kv[0] + " : " + kv[1]);
21st Jun 2019, 4:46 PM
RobertS
RobertS - avatar