JSFiddle - React, Tailwind, and code Playground

by hakim

JavaScript

var values = [ 'a', 'b', 'c', 'd' ];

// steps through all values and assigns the current value to 
// 'letter' on each iteration
for( var i = 0; letter = values[ i++ ]; ) {
    
    document.body.innerHTML += letter + ' ';
    
}

// bit of a weird one but was happy to discover a one-line 
// forEach-esque loop, the index ends up going from 1-4 rather 
// than 0-3








// of course if you wanted to be all like ES5 and stuff you'd just:

// values.forEach( function( letter ) {
//    document.body.innerHTML += letter + ' ';
// } );