今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Basic array methods 2
(upbeat music) - [Instructor] For this challenge, we've been given an array of numbers and a variable called start that is set to zero. We want to loop over this array and add each value to start. Traditionally, before we had the array method for each, we would use something called a for loop to loop over an array, and it was a little bit more verbose. For each has made this so much easier and cleaner, and so that's what we're going to use today to add up this value. So first, what we'll need to do is take our numbers array, and let's go ahead and apply the for each method, and I'm going to set up the callback function. We're going to pass number, which represents each number within the array. Now, one important thing to remember from the lesson, and you'll find as you go through the course, this varies depending on the array method, but for the for each array method, it does not return a new array. We're going to talk about an array method called map, we're going to talk about an…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。