Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.45 KB

operator&loops.md

File metadata and controls

44 lines (35 loc) · 1.45 KB

Operators&Loops

operators:

In JavaScript, an operator is a special symbol used to perform operations on operands (values and variables). For example, 2 + 3; // 5. Here + is an operator that performs addition, and 2 and 3 are operands.

What are the different types of operators in JavaScript?

  • JavaScript operators are used to assign values, compare values, perform arithmetic operations, and more.
  • JavaScript Arithmetic Operators. ...
  • JavaScript Assignment Operators. ...
  • JavaScript String Operators. ...
  • Comparison Operators. ...
  • Conditional (Ternary) Operator. ...
  • Logical Operators. ...
  • JavaScript Bitwise Operators. ...
  • The typeof Operator.

Loops:

What are the loops in JavaScript?

Loops are used in JavaScript to perform repeated tasks based on a condition. Conditions typically return true or false when analysed. A loop will continue running until the defined condition returns false . You can type js for , js while or js do while to get more info on any of these.

Loops are control structures used to repeat a given section of code a certain number of times or until a particular condition is met. Visual Basic has three main types of loops:

  1. for.. next loops,
  2. do loops
  3. while loops.

example(1):

for (let i = 0; i < cars.length; i++) { text += cars[i] + "
"; }

example(2):

while (i < 10) { text += "The number is " + i; i++; }

example(3):

do { text += "The number is " + i; i++; } while (i < 10);