I have an external JavaScript file that contains some calculations. The results are put into an array. I've written some 'get' functions to return the values of a passed in index value. In my HTML file, I've written a function to display the array on a new line every 1 second. Here is the code for that:
<script>
var showSequence = function (target, message, index, interval) {
if(index < message.length) {
$(target).append(message[index++]);
setTimeout(function (){ showSequence(target, message, index, interval); }, interval);
}
}
</script>
I call it like:
<body>
<script>
$function(){
for(var i = 0; i < getArrayLength(); i++){
showSequence('#calculations', getArrayValue(i) + '<br />', i, 1000);
}
}
</script>
<h1>Fibonacci Calculation:</h1>
<p id='calculations'></p>
However I get an unexpected token { error. Being new to JavaScript, I can't find a missing {. Looking for a little help on this.
', i, 1000) then the $funciton() that I am not sure if its legal or not but might be another implementation I just did'nt knew about. – Sebastien Sep 30 '14 at 21:55