Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Sets</h1>
<h2>The add() Method</h2>
<p>The add() method adds values to a set:</p>
<p id="demo"></p>
<script>
// Create a Set
const letters = new Set();
// Create Variables
const a = "a";
const b = "b";
const c = "c";
// Add Values as Variables to the Set
letters.add(a);
letters.add(b);
letters.add(c);
// Display the Size
document.getElementById("demo").innerHTML = "The set has " + letters.size + " values.";
</script>
</body>
</html>