+ 1
Help is needed with ES6 with loops and functions
I created multiple loops with JS, but in the last loop I put 3 values Blue, Red, and Green, but for some reason, only the last value of the list is output does anyone knows why? I'm trying to make all the values to display does anyone know how to do that as well? Here is the link to the code https://code.sololearn.com/W2XAVzvtwAYL/#js
3 Answers
+ 5
you used () when you want to create an array. it will cause the last "green" be stored in x as a string.
use [, ] instead.
+ 3
You are using parentheses instead of brackets.
This...
let x = ("Blue", "Red", "Green");
... should be this:
let x = ["Blue", "Red", "Green"];
Please also read this latest discussion to understand what's going on here:
https://www.sololearn.com/discuss/2152749/?ref=app
0
Thank you again, Gordon!