+ 3

New to JavaScript and teaching myself

I am trying to prompt the user for a color, then have the console report if the user typed a primary color (red, blue, or yellow) or a secondary color (orange, green or purple) or none of these. I also want to handle the situation for both uppercase and lowercase letters in the color the user types in. https://code.sololearn.com/WI5mGKZMIcdN/?ref=app

8th Sep 2021, 7:44 AM
Nick B
 Nick B - avatar
16 Réponses
+ 6
FYI, you can't use relational operators(< ,==,>) or logical operators(||,&&) to compare an input variable with an array element unless you're using a loop. Also, you can add Prasanth's code inside your script tag or use one of them for better look
8th Sep 2021, 8:29 AM
Simba
Simba - avatar
8th Sep 2021, 8:10 AM
Prashanth Kumar
Prashanth Kumar - avatar
+ 3
Nick B You have written in Java compiler not in JavaScript. Both are different.
8th Sep 2021, 8:05 AM
A͢J
A͢J - avatar
+ 2
Rather create new web code bit, and share its link than copy/pasting raw text code. https://www.sololearn.com/post/75089/?ref=app
8th Sep 2021, 7:58 AM
Ipang
+ 1
Nick, Wrong type of code bro ... Create your code in a new "Web" project, not "Java" project ... Please change it.
8th Sep 2021, 8:06 AM
Ipang
+ 1
Nick B Java and JavaScript are totally different programming languages dude!
8th Sep 2021, 8:06 AM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
Nick B No that's for temporary. I think you have accessed many times so SL blocked you for some time. After some time you will be able to write and run code in Web.
8th Sep 2021, 8:59 AM
A͢J
A͢J - avatar
+ 1
Kylar Cham It's a node js function.
8th Sep 2021, 12:51 PM
A͢J
A͢J - avatar
0
Nick B Single equal is used for assignment not for comparison. Use double equal (==).
8th Sep 2021, 8:06 AM
A͢J
A͢J - avatar
0
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ I only saw Java on the list
8th Sep 2021, 8:06 AM
Nick B
 Nick B - avatar
0
There is web option, you can write there
8th Sep 2021, 8:07 AM
A͢J
A͢J - avatar
0
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ I got blocked on the web version, and I don’t know why.
8th Sep 2021, 8:08 AM
Nick B
 Nick B - avatar
0
Prashanth Kumar ok just changed it
8th Sep 2021, 8:16 AM
Nick B
 Nick B - avatar
0
I was wondering, is readLine() a real JavaScript function? Because when I try to use it on another compiler, it says Error: readLine is not defined
8th Sep 2021, 11:29 AM
Kylar Cham
0
Nick B welcome to javascript
9th Sep 2021, 1:28 AM
Mayank Gupta
Mayank Gupta - avatar
0
Hii
9th Sep 2021, 10:12 AM
1 Mahanayak Bhim Rao Ambedkar
1 Mahanayak Bhim Rao Ambedkar - avatar