Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Map Objects</h2>
<p>Using Map.values():</p>
<p id="demo"></p>
<script>
// Create a Map
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);
let total = 0;
for (const x of fruits.values()) {
  total += x;
}
document.getElementById("demo").innerHTML = total;
</script>
</body>
<!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_map_values1 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 14:46:49 GMT -->
</html>