今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Sets 1
(upbeat music) - [Instructor] In this challenge, we're given an array of pet names and we need to create a new set based on this array. So the first thing that we'll need to do is actually establish our new set. So I want to point out from the beginning that there could be a couple different ways that you achieve the correct solution in this particular challenge. My way is not the only way. So keep that in mind when you are working through this. So the first thing that I'm going to do is I'm going to create a new variable and I'm going to call it petSet, and I'm going to set that equal to a new Set. Then I know I want to add each item that's in this namesForFamilyPet array. I want to add it to this new set. So what I'm going to do is actually iterate over this array, and, for each name, I'm going to add it to the set. So we will actually utilize our array methods here. So namesForFamilyPet and we're going to to use forEach here. And I'm going to say forEach(name) and I'm going to…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
The Set object defined57 秒
-
(已锁定)
Add values to your set3 分钟 17 秒
-
(已锁定)
Does Set have your value?3 分钟 9 秒
-
Get your set size2 分钟 2 秒
-
(已锁定)
Delete and clear values in your set2 分钟 46 秒
-
(已锁定)
Iterate over values in a set2 分钟 45 秒
-
(已锁定)
Iterate over a set with entries2 分钟 25 秒
-
(已锁定)
Iterate over your set with forEach2 分钟 29 秒
-
(已锁定)
Solution: Sets 12 分钟 8 秒
-
(已锁定)
Solution: Sets 22 分钟 35 秒
-
-
-