How to check if a string is contained in an array in Node.js

1 Answer

0 votes
const arr = ['javascript', 'typescript', 'node.js'];
const str = 'node.js';

if (arr.includes(str)) {
  	console.log('yes');
} else {
  	console.log('no');
}


  
  
  
  
/*
run:
  
yes
  
*/

 



answered Jun 26, 2022 by avibootz
...