How to use forEach() to print an array in reverse order in Node.js

1 Answer

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

 



answered May 17, 2022 by avibootz

Related questions

1 answer 116 views
1 answer 118 views
2 answers 154 views
154 views asked Mar 13, 2022 by avibootz
1 answer 107 views
...