Sonzaschool
Rudi

Sekondari ya Kawaida · Kidato cha Pili · Amali · Electronics and Computer

Computer Programming

Implementing selection, loop, and array

takriban dakika 4 kusoma

Majadiliano
Mada za sehemu hiiImplementing web scriptingMada 4

Selection, loops, and arrays are three fundamental building blocks that allow a program to make decisions, repeat actions, and store collections of data.

Selection statements let the program choose different actions based on conditions. The main types are if, else, and switch.

The if Statement

The if statement checks a condition. If the condition is true, the code inside the block runs.

let score = 75;
if (score >= 50) {
    console.log("You passed!");
}

The if-else Statement

When you want one action if the condition is true and a different action if it is false, use else.

let temperature = 30;
if (temperature > 35) {
    console.log("It is very hot today.");
} else {
    console.log("The weather is okay.");
}

The switch Statement

When you have many conditions to check against one value, switch is often clearer than many if statements.

let day = 2;
switch (day) {
    case 1:
        console.log("Monday");
        break;
    case 2:
        console.log("Tuesday");
        break;
    case 3:
        console.log("Wednesday");
        break;
    default:
        console.log("Invalid day");
}

Jinsi utakavyotathminiwaTathmini ya mchakato · Tathmini ya matokeo · Tathmini ya maarifa

Tathmini ya mchakato

  • Apply conditional statements (if-else, switch).
  • Use loops (for, while, do-while).
  • Declare and manipulate arrays.

Tathmini ya matokeo

Selection, loop and array are correctly implemented in scripts to perform the required tasks.

Tathmini ya maarifa

Detailed knowledge of:

Method used: The student should explain how to:

  • implement conditions, loops, and arrays.

Principles: The student should explain the principle of:

  • control flow and iteration.

Theories: The student should explain:

  • The concepts of flow control and arrays
  • use of arrays in storing and accessing data. Circumstantial knowledge:

Detailed knowledge about:

  • array methods

Swali

What is the index of the first element in a JavaScript array?

Ingia ili kuwasilisha jibu lako na lihesabiwe katika umahiri wako.

Ingia ili kufanya mazoezi

Mwalimu

Umekwama? Niulize chochote kuhusu mada hii.

Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu swali hili.

Ingia ili kuuliza

Majadiliano

Hakuna maswali bado

Ingia ili kuuliza
Inapakia majadiliano…