How to convert all values in a set to uppercase with TypeScript

2 Answers

0 votes
const st = new Set(['typescript', 'javascript', 'node.js', 'c++', 'c']);
 
const newset = new Set();
 
st.forEach(value => {
    newset.add(value.toUpperCase());
});
 
console.log(newset);
 
   
   
/*
run:
 
{"TYPESCRIPT", "JAVASCRIPT", "NODE.JS", "C++", "C"} 
 
*/

 



answered May 23, 2022 by avibootz
0 votes
const st = new Set(['typescript', 'javascript', 'node.js', 'c++', 'c']);
 
const newset = new Set(Array.from(st).map(value => value.toUpperCase()));
 
console.log(newset);
 
   
   
/*
run:
 
{"TYPESCRIPT", "JAVASCRIPT", "NODE.JS", "C++", "C"} 
 
*/

 



answered May 23, 2022 by avibootz
...