javascript for function 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: js function
function name(parameter1, parameter2, parameter3) {
// what the function does
}
Example 3: How to create a function in javascript
function addfunc(a, b) {
return a + b;
// standard long function
}
addfunc = (a, b) => { return a + b; }
// cleaner faster way creating functions!
Example 4: function js
function toCelsius(fahrenheit) {
return (5/9) * (fahrenheit-32);
}