How to use const in for loop with JavaScript ES6

1 Answer

0 votes
function f(...args) {
    for (const [index, element] of args.entries()) { 
        const s = index + '. ' + element; 
        console.log(s);
    }
}
f('JavaScript', 'Node.js', 'C++');




/*
run:
 
0. JavaScript
1. Node.js
2. C++
    
*/

 



answered Mar 15, 2020 by avibootz

Related questions

1 answer 150 views
2 answers 171 views
2 answers 237 views
1 answer 152 views
...