Loading ...

user Hausa Academy
6th Mar, 2025 11:47:17
JavaScript Programming

JavaScript Hausa #8: Understanding Operators

Hello! Welcome to the eighth lesson in our JavaScript series. Today, we’ll learn about operators—special tools in JavaScript that help you do actions like adding numbers, comparing values, and making decisions. Let’s get started!


What Are Operators?

Operators are like tools in JavaScript that help you work with data. They can add numbers, check if things are equal, or combine conditions. Here are the main types:

  • Arithmetic Operators: For math (e.g., +, -, *, /).
  • Comparison Operators: For checking if values are equal or which is bigger/smaller (e.g., ==, >, <).
  • Logical Operators: For combining conditions (e.g., &&, ||, !).
  • Assignment Operators: For saving values into variables (e.g., =, +=, -=).

Examples of Operators

1. Arithmetic Operators:

let num1 = 10;
let num2 = 5;
console.log(num1 + num2); // Shows 15
console.log(num1 - num2); // Shows 5

2. Comparison Operators:

let age = 20;
console.log(age > 18); // Shows true (age is over 18)
console.log(age == 20); // Shows true

3. Logical Operators:

let isStudent = true;
let hasMoney = false;
console.log(isStudent && hasMoney); // Shows false (both must be true)
console.log(isStudent || hasMoney); // Shows true (either one is true)

Why Are Operators Important?

Operators are important because:

  • They help you do math and comparisons easily.
  • They make your code shorter and easier to read.
  • They are used in almost every part of programming.


Watch This Video for More Guidance

To see operators in action, check out this video. It shows how to use them step-by-step:


Final Thoughts

Congratulations! You now know about JavaScript operators. They’re like the building blocks of code logic. Practice using them in your projects to get better. Next lesson, we’ll explore more cool topics. Keep coding and have fun!

Thanks for reading, and happy coding!


Share This Article

Comments

Leave a comment

Blog categories