Help my code not work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help my code not work

ReferenceError: "idk" is not defined https://code.sololearn.com/c316KrpPFB26/?ref=app

9th Mar 2022, 1:52 AM
sussy baka
6 Answers
+ 2
At line 7 ”(idk ==sus)" .. it gives you the error because it's outside of the function, a variable declared inside a function is local and can be accessed only inside that function. Also would recommend to use let or const keyword to declare variables unless you're making something that had to work on a browser version older than 2015.
9th Mar 2022, 5:58 PM
Aleksandar Aleksovski
Aleksandar Aleksovski - avatar
+ 2
i think you can writ (let idk) , var isn't good . 🤔
10th Mar 2022, 7:58 PM
Mani
Mani - avatar
0
Firstly, you haven't called your main function so the variable idk is never defined in your code & secondly, you don't read input with just readline() in the nodejs.
9th Mar 2022, 5:56 AM
zexu knub
zexu knub - avatar
0
Ok 1st thing don't use the main function it has no use in the code
9th Mar 2022, 6:02 AM
zexu knub
zexu knub - avatar
0
2nd: that's how you take the user input from the readline module https://www.geeksforgeeks.org/node-js-readline-module/
9th Mar 2022, 6:04 AM
zexu knub
zexu knub - avatar
0
It's because sus is not being declared and assigned and instead of a function in var idk,replace it with something else
10th Mar 2022, 6:48 PM
Denzel TAKYI
Denzel TAKYI - avatar