How to use forEach() to print an array in reverse order in TypeScript

1 Answer

0 votes
const array = ['c++', 'typescript', 'c', 'java'];
  
array
  .slice()
  .reverse()
  .forEach(element => {
    	console.log(element); 
  });  
  
  
  
  
  
/*
run:
  
"java"
"c"
"typescript"
"c++"
  
*/

 



answered May 17, 2022 by avibootz

Related questions

1 answer 127 views
1 answer 94 views
1 answer 121 views
2 answers 127 views
1 answer 78 views
...