Technical Article
92 views0 likes

Loops and functions

Structure of loop

Offor Janefrances
November 8, 2025
3 months ago

Loops:
Loop is used to write codes that perform a repetitive task.

Structure of loops
for ( Initialize; Condition; Increment)

Example:
let username = "John";
for (let I = 1; I <=5; I++) {
Console.log(username);
}

Break and continue are interruption to your loop.

example;

for ( let I =1; I<=10; I++) {
If (I===5) break;
Console.log(I);
}

for ( let I =1; I<=10; I++) {
If (I===2) continue;
Console.log(I);

. Length is a property that returns numbers, you can use it on strings or arrays.

Example;
Let myArray = [ 2,3,4]
Console.log(myArray.length)
( It will run "3" )

What are FUNCTIONS in JavaScript?

Functions are reusable blocks of code that carry out or perform a specific task.

Structure of a Function.
Function greet ( ) {
Console.log ( "Helo class ");
}

Greet ( ); ( is a function call)

Function Syntax

  1. Function declaration: function functionName(parameters) { ... }
  2. Function expression: let functionName = function(parameters) { ... }
  3. Arrow function: let functionName = (parameters) => { ... }

Function Parameters and Arguments

  1. Parameters: Parameters are used to call a function, there are also variables declared in the function signature.

  2. Arguments: Arguments are the value of the parameter, values passed to the function when it is called.

Example;
Function second greet(name) {
Console.log( "Hello" + name);
}
secondGreet("Jane")

In the above example, "name" is the parameter and "Jane" is the Argument

Pass in the argument when you call the function and specify parameters when you define the function, our mentor Ndubueze nwoko made sure we have a reasonable understanding of Functions!

Hoisting: Having access to a variable or a function before you declare it ( calling a function before declaring it)

Return Values

  1. Return statement: Used to specify the value returned by the function.

  2. Undefined: If no return statement is specified, the function returns "undefined".

Last updated: February 4, 2026

Written by: Offor Janefrances

More Articles

Deep Technology's

We are on an unwavering mission to be Nigeria's most loved software company, helping people discover new problem-solving strategies to solve problems around the globe.

NO 33 Democracy Crescent, Gaduwa Estate Gudu,Abuja FCT, Nigeria

© 2026 Deep Technology's. All rights reserved.