Комментарии:
Theres a great chance that things have changed in the 2 years since this video posted, but when I try to work along, I get a long string of numbers instead of the sum total:
const totalMass = characters.reduce((acc, cur) => acc + cur.mass, 0);
console.log(totalMass);
0771364984
do u have an explanation for react plz??
ОтветитьWhat's the name of your theme sir?
ОтветитьWhat's the name of your font sir?
ОтветитьThanks
ОтветитьMe again, I forgot it all :D
Ответитьnice, the biggest "aha" moment for me was realizing you can set the initial value to be an empty object
ОтветитьCan anyone clarify why acc[cur.eye_color] works but same with dot notation acc.cur.eye_color doesn't work??
ОтветитьGreat videos! Thx man :)
PS color theme do you use?
Not sure if maybe something in JS has changed since this video but for totalMass, I kept getting 0771364984 so I knew it was being concatenated as strings so I tried commenting out 'use strict' and also tried taking quotes off the numbers in the characters array but the only fix was wrapping cur.mass in Number() in the return. I'm sure parsint etc probably works too Just incase someone else has this problem and is spinning their wheels.
Ответитьhow can i find more challenges ? thank you!
ОтветитьWell explained thanks.
ОтветитьGreetings from Bulgaria. Thank you for your time and efforts to put those wonderful tutorials.
Please, tell me in the case of eye colors, how that object got miraculously arranged into those exact key value pairs, since nowhere you specified that ?
Thank you.
need more class
ОтветитьCan you show how to sort an array of strings case sensitive? e.g. Luke, leila, Darth, yoda
ОтветитьI gave you a thumbs up. The video is mostly clear. I wish you would have explained why you started with an empty object. With that being said I have seen several examples of using the reduce method with objects and this is one of the more clear explanations even though I do not understand why you start with an empty object.
ОтветитьFlawless explanations! thank you
ОтветитьThanks 👍
ОтветитьThis and the map vieo were helpful - thanks! I forgot to sub to your channel when I saw your video on Brad Traversy's channel.
ОтветитьDitto.... Sorry to sound like a broken record. But another great video ;)
ОтветитьI wonder the people giving thumbs down for this lovely easy to understand video 🤔, can we see something better from you lots giving thumbs down then.
ОтветитьThe best video I found with Reduce() examples. THANK YOU SO MUCH!!
ОтветитьFirst time watching your vids - this was an easy sub for me - really love your vids and explanations - it has been helpful - thank you
ОтветитьDude, over 10k views but only 579 likes? That dog won't hunt.
ОтветитьGreat series on the JS array methods, thanks!
ОтветитьThe eye color example was really good, thanks
Ответитьif you downloaded array from github, you should convert mass from string to number for it to work: +acc + +cur.mass
Ответитьniced
ОтветитьBack again for a refresher; by far the most extensive tutorial on this topic
Ответитьmap and reduce are such bizarrely named functions...
ОтветитьExcellent video.
Suggestion 1: Turn off vs code intellisense so the popup does not cover your code.
Suggestion 2: Put the terminal on the right
Suggestion 3: run 'nodemon worksheet.js -q' to hide nodemon status and clean up the console
This was quicker than ‘looking it up’ thanks 👍
ОтветитьI don't understand the eye color " if (acc[color]) " this if statement checks if color exists right? I don't understand how it decides to count the same color and don't understand the false statement either if color doesn't exist then you set color to true? this if statement is confusing.
ОтветитьJust what i'm looking for. Great work. I'm a looooonnnnng time SQL programmer and new to javascript (which is my new retirement hobby). I was always wondering how in javascript to do a simple "Select EyeColour, count(*) from Characters group by EyeColor". This has opened my eyes! (Which are blue by the way if you need to add that to the data set. 😁)
ОтветитьWow! Thanks a ton. Can you please make a video on how you've customized your VS code and zsh?
Ответитьto difficult for me.. :/
ОтветитьHi James Q Quick , your tutorials are simply awesome, In reduce function example the output of totalMass producing incorrect result(0497784136) , we have to apply parseInt to curr.mass i.e characters.reduce((acc, cur) => acc + parseInt(cur.mass),0). so that we will get correct result(346). Thanks for your Great Tutorials.
ОтветитьFuck no dislikes yet 🙄😯 is it a sign to hope in humanity again?😁
ОтветитьGreat stuff! I'll always go back to this playlist!
ОтветитьWondering if you can return values as arrays and don't return duplicates:
{
eye_color: ["brown","blue","green"]
}
I just have a problem, my values are concatenate. I try with Math but nothing =(
Ответитьis there a reasone not to use syntax like: arr["index"] = (arr["index"]||0) +1; to handle initialization of unused indexes to skip the if else?
ОтветитьHey,i have put every bit of effort to figure out what am i doing wrong, but i am getting this number as total of mass <0771364984>.I have rechecked countless times, i have the exact same code but with different number.
Ответитьty
ОтветитьMy English is not very good but I really understand it with your explanation, I like your style in explaining and the font used is quite pleasing to the eye with an explanation and a font size that is very suitable and comfortable to see and hear, awesome .. I hope you explain more in detail like this and more tutorials about javascript on your channel cz this tutorial is great!
ОтветитьI LIKE YOU PJ'S!!!!! if they are pj's
ОтветитьI was the 69th like, nice
Ответитьthank you so much but i have a doubt , instead of ""curr.mass'" can we write it using destructuring if yes then how?
Ответить