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 
// Array.forEach-esque loop. Could of course be done using 
// while() at the cost of an extra outside variable 
// declaration (omg!).
//
// The index property goes from 1-4 rather than 0-3.