今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Sets 2
(upbeat music) - [Instructor] For this challenge, we're given an array of guesses. We're also given a winning number, and we need to determine, is that winning number in our guesses set that we're going to create? So the first thing that we want to do is set up our set. So very similar to the challenge that you just completed. We're going to go ahead and create a new variable, and I'll call that guessesSet, and we'll instantiate a new set here. Then, very similar to last time, I'm going to loop over this guesses array, and for each value, I'm going to add it to our set. As I mentioned before, there could be a number of different ways that you decide to do this. I'm going to show you one way that's going to give you some practice with array methods as well. If you choose to do it another way, that's totally fine, as long as you get the correct answer or solution and using a set, then you've done what you're supposed to do. So let's go ahead and we'll reference our array of guesses, and…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
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 秒
-
-
-