Print elements of a set as a string in JavaScript
In this tutorial, you are given a set of elements. Write a JavaScript program to print elements of the set as a string.
Solution
To print the elements of a set as a program, convert the set to array, and join the elements of the set using a required separator.
[...mySet].join(', ')
Program
1. Print the elements of the set vowels
as a string.
const vowels = new Set(['a', 'e', 'i', 'o', 'u']);
console.log([...vowels].join(', '));