html
html
1
Enter to Rename, Shift+Enter to Preview
css
css
1
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
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.
Hint: remember the || means 'or'
The app won’t let me copy and paste on here
*/
var color=prompt("Enter a color :","red");
color=color.toLowerCase(); // this will make color lowercase
var primaryColors=[
"red","blue","yellow", // you can add more here
];
var secondaryColors=[
"orange","green","purple", // you can add more here
];
if(primaryColors.includes(color)){
console.log(color+" is primary color");
} else if(secondaryColors.includes(color)) {
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run