for function javascript code example

Example 1: javascript for loop

var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) { 
  console.log(colors[i]);
}

Example 2: for loop javascript

var i;
for (i = 0; i < cars.length; i++) {
  text += cars[i] + "<br>";
}

Example 3: javascript for loop

for (var i; i < 10; i++) {
  
}

Example 4: simple javascript function

function idk() {
	alert('This is an alert!')
}
//call the function to make the function run by saying "Name of function + ()"
idk()

Example 5: declare function javascript

function myFunction(var1, var2) {
  return var1 * var2;
}