Comparison operators 2 JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Comparison operators 2 JavaScript

I have no idea how to solve this at this point, tried multiple things. Not sure if I’m going in the right direction, Can someone help please? Issue: You are given a program that takes the age of the user as input. Complete the code to check if the user is an adult, and output to the console the corresponding boolean value. function main() { var age = parseInt(readLine(), 10) // Your code here if (age >= 18) { return true; } else { return false; } } console.log(main())

14th Jul 2021, 12:06 PM
Angelika Halicka
2 Answers
0
if this is a sololearn course pratice task, the main function is called by test cases... so you doesn't need to call it yourself, and you rather must console.log() from inside the main() function ;)
14th Jul 2021, 12:12 PM
visph
visph - avatar
0
function main() { var age = parseInt(readLine(), 10) // Your code here // let age = 20 if (age >= 18){ console.log(true); }else { console.log(false); } }
14th Jun 2022, 11:19 AM
Bonfacekiprop
Bonfacekiprop - avatar