
FUNCTION
A JS function is a block of code designed to perform a particular task and is executed when "something" invokes it (calls it).
We can submit 0, 1, or more parameters to a function.
ex.
function functionName(parameter1, parameter2, parameter3) { // code to be executed}
FUNCTION & RETURN STATEMENT
The return value is "returned" back to the "caller".
ex.
function myFunction(a, b) { return a + b;}console.log(myFunction(5, 6))// Function returns 11
LOOPS
Loops are used in JS to perform repeated tasks based on a condition. Conditions typically returntrue orfalse when analysed. A loop will continue running until the defined condition returnsfalse.
FOR LOOP
for ([begin]; [condition]; [step]) { // statement}
ex.
for (let i = 0; i < 10; i++) { console.log(i)}
WHILE LOOP
The while loop starts by evaluating the condition. If the condition istrue, the statement(s) is/are executed. If the condition isfalse, the statement(s) is/are not executed. After that, while loop ends.
while (condition){ statement(s);}
ex.
let i = 0;while (i < 10) { console.log(i); i++;}
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse