A little glimpse into JavaScript 'For Loops'.
Code:
arr = ['Fortran', 'Python', 'C++', 'Assembly', 'Binary'];
for (x in arr) {
document.write(x);
}
document.write('<br>');
for (var i = 0; i < arr.length; i++) {
document.write(i);
}
document.write('<br>');
for (x of arr) {
document.write(x + ' ');
}
document.write('<br>');
for (var i = 0; i < arr.length; i++) {
document.write(arr[i] + ' ');
}
Result:
01234
01234
Fortran Python C++ Assembly Binary
Fortran Python C++ Assembly Binary
No comments:
Post a Comment