今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Maps 1
(upbeat music) - [Instructor] Welcome to your first CoderPad challenge for maps. For this particular challenge, we're going to set up a map and then we're going to determine the map size. So below in our test code, you can see that we already have a new map of fruit inventory set up for us. So now we just need to add individual items to that map. And then we're going to return the size of a map to test our solution. So the first thing that I'll do is start with our fruit inventory and then we're going to use the map method set to add each item in the inventory. So our first value here is going to be the key, which will be apples, and then the value of 10. So we'll just go right down the line with each of these items and add it to our map. So oranges 15 value, and then bananas right after. And that has a value of 20. Excellent. So we have all our items added to the map. Now we need to determine the size. So we're going to use the size property to do so. So fruit inventory, spell that…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
The Map object defined1 分钟 23 秒
-
(已锁定)
Build your Map object with the set method4 分钟 41 秒
-
(已锁定)
Access a value with get3 分钟 51 秒
-
(已锁定)
Does the map have your key?3 分钟 4 秒
-
(已锁定)
Determine map size2 分钟 6 秒
-
(已锁定)
Remove key-value pairs with clear and delete4 分钟 23 秒
-
(已锁定)
Map: Keys and values methods5 分钟 44 秒
-
(已锁定)
Map contents with the entries method2 分钟 32 秒
-
(已锁定)
Loop over a map with forEach2 分钟 38 秒
-
(已锁定)
Group entries with groupBy3 分钟 22 秒
-
(已锁定)
Solution: Maps 12 分钟
-
(已锁定)
Solution: Maps 21 分钟 32 秒
-
-
-
-
-