Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Maps</h1> <h2>The set() Method</h2> <p id="demo"></p> <script> // Create a Map const fruits = new Map(); // Set Map Values fruits.set("apples", 500); fruits.set("bananas", 300); fruits.set("oranges", 200); let numb = fruits.get("apples"); document.getElementById("demo").innerHTML = "There are " + numb + " apples."; </script> </body> </html>