lmfao ive been doing js for like 5 months and i always seem to gorget basics. this lesson will forever have it engrained in my head. thank u! best tutorial so far. gonna start following u !
My code is not working can u figure out why..? var fruits=["apple","mango","banana","orange"]; fruits.foreach(function(fruit){ document.write(fruit+"") });
@@Just_a_girl_in_a_new_city two things i see... one is that its forEach... and number two is you should use template literals. much better for adding html into your code (you should also get used to arrow functions for array methods like this. hope that helps! the only thing you reallllly had to fix is the forEach though :) var fruits=["apple","mango","banana","orange"]; fruits.forEach(fruit=>{ document.write(`${fruit} `) })
@@Just_a_girl_in_a_new_city also make sure if you use template literal syntax ${} like that you should begin and end it with backticks. NOT regular quotation marks.... ` ` instead of ' '
@@Just_a_girl_in_a_new_city good stuff. if i were you i would try JS 30 for 30 array cardio exercises. i dont think he does forEach in the tutorial but he shows you ALOT of other methods (filter, reduce, map) etc... they will take a lot of practice ! do not give up! th-cam.com/video/HB1ZC7czKRs/w-d-xo.html
Dude, thank you so much for explaining it the easy way! I finally get it. I was struggle with the difference between for loop and forEach! this makes so much sense now! Also love the format of your video, always nice to see your face and the code side by side :P keep crushing it!
@@Just_a_girl_in_a_new_city will you double check foreach? it should be forEach sometimes it errors out when its not capitalized properly. fruits.forEach ( (fruit)=> document.write( fruit = fruit + ""))
@@Just_a_girl_in_a_new_city you might need to double check on the document.write and syntax, i wrote this on the fly without checking in my text editor
Nice touch with giving parameters real names. Tho, you didn't mention the fact that there can be up to 3 parameters inside forEach function, first always stands for item in the array, second for item's index & third for an array. All in all, good video. Thanks man! Keep it going.
Hi Mike, great tutorial and it helped me understand forEach loops better. Question; Instead of using document.write(book.name + "") document.write(book.author + "") document.write(book.pages+ "
yes. you can also use template literals to do this. (best way imo) document.write(`${book.name} + ${book.author} + ${book.pages}`) dont forget it uses BACK ticks with this format and not regular quotation marks!
no. forEach iterates through each item in the array. it wont stop until it is done. basically whatever callback function you write will be applied to each item in the array one at a time. a break won't stop the function and there would be no real way to specify where a break would be in this case
you could probably use a reduce method to add up all the page numbers and then divide by the number of books..... reduce is an array method that essentially turns an array into one single value. reduce method would be easiest way to do it. if you have trouble with them MDN has some great examples so you can really master using them
Hey Mike, it's a great tutorial but your video is so distracting. You can show yourself a few times between the tutorial but not all the time in front of the code. To be honest, people won't be interested to watch you because they are watching to learn something. You can introduce yourself in the beginning or say goodbye at last like at 6:15 (u look gud)
Finished Tutorial 26.Thanks to Mike. Almost finishing ..
so awesome...Mike. So far I've learned and python, javascript, c# and C from you. Thanks so much for creating those videos.😀
Another great tutorial. Thank you Mike!
You are a very good teacher. Some little tutorials I've just also watched for the forEach function were ridiculously complicated.
Wow amazing. you made it so easy to understand. thank you very much.
for real, I was struggling today,, thanks to this video
This is the best explanation of forEach.
ive been stuck on this for 4 days. your video has finally made it clear.
Mike, you make my day. Since morning I was looking to understand it in so simple way.
Many thanks
lmfao ive been doing js for like 5 months and i always seem to gorget basics. this lesson will forever have it engrained in my head. thank u! best tutorial so far. gonna start following u !
My code is not working can u figure out why..?
var fruits=["apple","mango","banana","orange"];
fruits.foreach(function(fruit){
document.write(fruit+"")
});
@@Just_a_girl_in_a_new_city two things i see... one is that its forEach... and number two is you should use template literals. much better for adding html into your code (you should also get used to arrow functions for array methods like this. hope that helps! the only thing you reallllly had to fix is the forEach though :)
var fruits=["apple","mango","banana","orange"];
fruits.forEach(fruit=>{
document.write(`${fruit} `)
})
@@Just_a_girl_in_a_new_city also make sure if you use template literal syntax ${} like that you should begin and end it with backticks. NOT regular quotation marks.... ` ` instead of ' '
@@BobbyBundlez tnks to u , it worked.
@@Just_a_girl_in_a_new_city good stuff. if i were you i would try JS 30 for 30 array cardio exercises. i dont think he does forEach in the tutorial but he shows you ALOT of other methods (filter, reduce, map) etc... they will take a lot of practice ! do not give up!
th-cam.com/video/HB1ZC7czKRs/w-d-xo.html
Dude, thank you so much for explaining it the easy way! I finally get it. I was struggle with the difference between for loop and forEach! this makes so much sense now! Also love the format of your video, always nice to see your face and the code side by side :P keep crushing it!
Plx help me ..this is not working.
var fruits=["apple","mango","banana","orange"];
fruits.foreach(function(fruit){
document.write(fruit+"")
});
@@Just_a_girl_in_a_new_city will you double check foreach? it should be forEach sometimes it errors out when its not capitalized properly. fruits.forEach ( (fruit)=> document.write( fruit = fruit + ""))
@@Just_a_girl_in_a_new_city you might need to double check on the document.write and syntax, i wrote this on the fly without checking in my text editor
@@VickyMei it worked tnku much
@@Just_a_girl_in_a_new_city welcome!! was it the capitalization?
Thank you, Mike. You helped me a lot in my class that I am taking.
Nice touch with giving parameters real names.
Tho, you didn't mention the fact that there can be up to 3 parameters inside forEach function, first always stands for item in the array, second for item's index & third for an array.
All in all, good video. Thanks man! Keep it going.
Thanks man, this is really helpful! I prefer to use forEach especially coming from PHP.
Awesome explanation, very easy to follow. Thank you!
Great simple explanation! Thanks for creating this content.
Dude... you just flat out rock.
LOVE your channel!
Thanks a bunch! Has anyone told you that your doppelganger is Nolan Sotillo? My goodness, you guys look like brothers.
Hi Mike, great tutorial and it helped me understand forEach loops better.
Question; Instead of using
document.write(book.name + "")
document.write(book.author + "")
document.write(book.pages+ "
Yes. That's what I did.
yes. you can also use template literals to do this. (best way imo) document.write(`${book.name} +
${book.author} +
${book.pages}`)
dont forget it uses BACK ticks with this format and not regular quotation marks!
Yes (thanks for the tip though)
Awesome explaination!!! Moreover want to know nesting of foreach
Very easy to understand and follow, Thanks!
This explanation was easy to understand, thanks! I will sub.
But can we use continue or break in this loop?
no. forEach iterates through each item in the array. it wont stop until it is done. basically whatever callback function you write will be applied to each item in the array one at a time. a break won't stop the function and there would be no real way to specify where a break would be in this case
Great explanation!
Man, you made it so easy for me.Thanx a lot !
Mike you're the best
Your are the best boss.
I finally understand this! Thank you for explaining it so well. None of the other written or video tutorials managed to make it so simple.
clear and easy understanding 👍 / thank you so much🌹🌹🌹
VERY clear!
Great Mike ! Thank you.
Wait how do nameless functions get arguments passed through
So good tutorial
How about to find the average number of pages per book?
you could probably use a reduce method to add up all the page numbers and then divide by the number of books..... reduce is an array method that essentially turns an array into one single value. reduce method would be easiest way to do it. if you have trouble with them MDN has some great examples so you can really master using them
because of this video i like ,comment subscribed!
I Love you buddy you helped me a lot Hope I can Support you Soon
thanks Mike
very simple explanation thank u !
Thank you!
great video thanks
Great! Thanks :)
tnx so much
Thanks!
New subscriber here
thank u mike
was so good
Nice video but you guys zoomed too much
are we just going to ignore the office reference
Hey Mike, it's a great tutorial but your video is so distracting. You can show yourself a few times between the tutorial but not all the time in front of the code. To be honest, people won't be interested to watch you because they are watching to learn something. You can introduce yourself in the beginning or say goodbye at last like at 6:15 (u look gud)