JavaScript Code

How to print elements of a set as a string in JavaScript?


Problem Statement

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(', '));


copyright @2022