You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 09-Data-Structure-Modern-Operators-and-Strings/README.md
+61
Original file line number
Diff line number
Diff line change
@@ -481,3 +481,64 @@ We an also use the `rest` on `DOM` elements, which allows us to do advanced func
481
481
```js
482
482
rest.get(document.querySelector("h1"));
483
483
```
484
+
485
+
### Maps Iteration
486
+
487
+
Elements are added to a `Map` using the `set()` method. But this can be cumbersome if you're trying to add multiple elements at the same time. To fix that, we can create a new `map` using an array inside the `map`.
488
+
489
+
For example:
490
+
491
+
```js
492
+
constquestion=newMap([
493
+
["Question", "What is the best programming language in the world?"],
494
+
[1, "C"],
495
+
[2, "Java"],
496
+
[3, "JavaScript"],
497
+
["Correct", 3],
498
+
[true, "Correct 🎉"],
499
+
[false, "Try Again 💔"],
500
+
]);
501
+
```
502
+
503
+
This method makes it easier but in any case where we need to keep adding elements to the `Map` programtically, the `set()` method is best.
0 commit comments