How to convert all values in a set to uppercase with Node.js

2 Answers

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

 



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

 



answered May 23, 2022 by avibootz

Related questions

1 answer 123 views
1 answer 203 views
1 answer 131 views
1 answer 152 views
1 answer 125 views
1 answer 120 views
...