On Loops/Arrays 2, what does the names[i] do?


#1

I just confused on why we have to do console.log("..." + " " + names[i]);


#2

@webjumper49018: That's just being used so you can print a message with a calculate/stored value with it.
Just a nice way to do it using just one console.log() other than using two of them.


#3

sorry im still a tad confused. What would it look like if I used two different statements?


#4

@webjumper49018: I'm not sure how it is on your lession but I'll give you an example.

var anyValue = 100 + 200
console.log("Result is")
console.log(anyValue)


This will print in two different lines.
In order to print in one line, you can either do like it was shown to you or simply add a comma, right after last double quotes.

var anyValue = 100 + 200
console.log("Result is", anyValue)

Edit: But follow the instructions that were given to you on your lession!


#5

okay, I think that I understand. I will do this from now on just because it works.


#6

@webjumper49018: I'd suggest to use what the instructions are telling you!
Not following them can block your way too next lessons.