Javascript doubt in challenge questions. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Javascript doubt in challenge questions.

https://code.sololearn.com/WvXXs7YBLTxB/?ref=app

3rd Dec 2021, 2:29 PM
gokul b
gokul b - avatar
3 Answers
+ 3
gokul b Or operator returns only first true value true || false = true false || true = true In this example a is undefined and b is null and both a and b are not value. c and d has value and both are true so first true value will be return So 4 || 'five' = 4 if you write d || c then 'five' will be return.
3rd Dec 2021, 3:27 PM
A͢J
A͢J - avatar
+ 3
gokul b let is blocked scope variable means if you define let in if condition then you cannot access outside if block if (true) { let a = 'abc'; } console.log(a) //error if (true) { var a = 'abc'; } console.log(a) //print abc https://www.sololearn.com/post/1280529/?ref=app
3rd Dec 2021, 3:37 PM
A͢J
A͢J - avatar
+ 1
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ thanks. And please define let.
3rd Dec 2021, 3:31 PM
gokul b
gokul b - avatar