-
-
Save bennadel/0d02b5680c506fae56b9b77a49810441 to your computer and use it in GitHub Desktop.
Dynamically Define For-Loop Increment In ColdFusion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- ColdFusion mechanics. ---> | |
<cfscript> | |
(() => { | |
var fromAscii = asc( "a" ); | |
var toAscii = asc( "z" ); | |
for ( var i = fromAscii ; i <= toAscii ; i += step /* VARIABLE */ ) { | |
echo( chr( i ) & " " ); | |
// Randomly define the next for-loop increment. | |
// -- | |
// Note: the step variable is hoisted to the top of the Function and is | |
// available for consumption in the for-loop mechanics. This is a feature of | |
// the language, not a bug. Hosting is aces! | |
var step = randRange( 1, 8 ); | |
} | |
})(); | |
</cfscript> | |
<!--- JavaScript mechanics. ---> | |
<script type="text/javascript"> | |
(() => { | |
var fromAscii = "a".charCodeAt(); | |
var toAscii = "z".charCodeAt(); | |
for ( var i = fromAscii ; i <= toAscii ; i += step /* VARIABLE */ ) { | |
console.log( String.fromCharCode( i ) ); | |
var step = ( 1 + Math.floor( Math.random() * 8 ) ); | |
} | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment