How to check if a string is contained in an array in TypeScript

1 Answer

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

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


  
  
  
  
/*
run:
  
"yes"
  
*/

 



answered Jun 26, 2022 by avibootz
...