Bro, You are doing a great job, and I appreciate your efforts. I specifically search your channel for tutorials so, don't stop you will be great youtuber
your chancel is god send! thanks for everything u do. I'm following colt's JS course and loop was confusing the hell out out of me but u explained it way much better in my opinion.
Can I turn the following into Ternary Operator? If so how? if (i === character.length - 1) { info += `and ${characters[i]}, `; } else { info += `${characters[i]}, `; }
If I'm correct; here is my understanding of it. You know, since the array is four based on the number of items stored in CHARACTERS. Meaning, characters.length = 4 since that's the length of the array if we are to check it. Hence, character.length - 1 = 3, just like saying 4 - 1 = 3. Hope you understand.
Also, I guess what he meant in that if statement is that; if i = 3 OR i === characters.length - 1 also know as I === 4 - 1 which is = 3. We should loops around that or iterate(i++), iterate or gives us Sonic, Tails and Mario then append them to info += ` and ${characters[i], in this place. characters [i] which is equal to 3 based on characters.length -1 (or 4-1) is Luigi. That's how I guess he did. Not sure tho. I hope he sees this or anybody and correct if I'm wrong. Thanks!
The answer you're looking for lies in the index start value. First value of every array index is defined as 0(zero), so an array of four values would be indexed as 0, 1, 2, 3. Example; let names = ['Mike', 'Brad', 'John', 'Stupid Trump']; Total length of this array would be 4 as there are 4 values(names) in it but as every array index start from 0, Mike would be indexed as 0 and Trump would be indexed as 3. So when you say ".length -1", you are basically saying it to stop when the index value comes to 3 (4-1 or 'array length -1) which is equal to the last value of the index (3) which is Trump in this example case. Hope this helps!
const colours = ["red", "Orange", "Blue", "Pink", "black"] for (let i = 0; i < colours.length; i++) { console.log(`${colours[i]} is my fav colour`); } //Output:- // red is my fav colour // Orange is my fav colour // Blue is my fav colour // Pink is my fav colour // black is my fav colour
Best explanation I’ve seen so far!! Thanks so much. I still want to understand more about the initialiser but is becoming more clear.
Bro, You are doing a great job, and I appreciate your efforts. I specifically search your channel for tutorials so, don't stop you will be great youtuber
Absolutely loving this course. You explain everything so well! this is one of the best explanations out there
Thank you for making it so simple...
your chancel is god send! thanks for everything u do. I'm following colt's JS course and loop was confusing the hell out out of me but u explained it way much better in my opinion.
Thank you so much! Appreciate the love and support! 🙂👍
Very helpful, thank you
You are amazing
Where does this -1 came from plz ??
Great job! 🧐
Thank you 🙂👍
Please reply me i don't understand this ${characters[i]}
Can I turn the following into Ternary Operator? If so how?
if (i === character.length - 1) {
info += `and ${characters[i]}, `;
} else {
info += `${characters[i]}, `;
}
thanks!
pls come back to youtube
( length - 1 ) how dose it work ? i didn't get this part
If I'm correct; here is my understanding of it. You know, since the array is four based on the number of items stored in CHARACTERS. Meaning, characters.length = 4 since that's the length of the array if we are to check it. Hence, character.length - 1 = 3, just like saying 4 - 1 = 3. Hope you understand.
Also, I guess what he meant in that if statement is that; if i = 3 OR i === characters.length - 1 also know as I === 4 - 1 which is = 3. We should loops around that or iterate(i++), iterate or gives us Sonic, Tails and Mario then append them to info += ` and ${characters[i], in this place. characters [i] which is equal to 3 based on characters.length -1 (or 4-1) is Luigi. That's how I guess he did. Not sure tho. I hope he sees this or anybody and correct if I'm wrong. Thanks!
The answer you're looking for lies in the index start value. First value of every array index is defined as 0(zero), so an array of four values would be indexed as 0, 1, 2, 3.
Example;
let names = ['Mike', 'Brad', 'John', 'Stupid Trump'];
Total length of this array would be 4 as there are 4 values(names) in it but as every array index start from 0, Mike would be indexed as 0 and Trump would be indexed as 3.
So when you say ".length -1", you are basically saying it to stop when the index value comes to 3 (4-1 or 'array length -1) which is equal to the last value of the index (3) which is Trump in this example case.
Hope this helps!
Hi Dev dreamer please upload full we development project as you done in a css project plzzz Dev dreamer upload video
👍
const colours = ["red", "Orange", "Blue", "Pink", "black"]
for (let i = 0; i < colours.length; i++) {
console.log(`${colours[i]} is my fav colour`);
}
//Output:-
// red is my fav colour
// Orange is my fav colour
// Blue is my fav colour
// Pink is my fav colour
// black is my fav colour
can anyone explain why all of a sudden the variable began with const instead of let that we have been using with mostly everything?
I guess he used const since we are not going to be reassigning or redeclaring the array or characters.