Skip to main content


Showing posts with the label JavaScript Fundamentals

JavaScript Conditional Statements

  JavaScript's Conditional Statements Overview  JavaScript's conditional statements provide the ability to execute different blocks of code depending on whether a certain condition evaluates to true or false. In this way, developers can create dynamic code that reacts to changing data or user input. Here are some examples of how to use conditional statements in JavaScript. If Statement The if statement is the most basic conditional statement in JavaScript. It allows you to execute a block of code only if a certain condition is true. Example One In the above example, I have given the code checks whether the age variable is greater than or equal to 18. If it is, the first block of code (inside the curly braces) will be executed and "You are old enough to vote." will be logged to the console. If the condition is false, the second block of code will be executed and "You are not old enough to vote yet." will be logged into the console. Example Two In the above ex

JavaScript Operators (Arithmetic, Assignment, Comparison, Logical Conditional Ternary, Bitwise)

  JavaScript, operators are symbols or keywords used to perform operations on one or more values. JavaScript has several types of operators, which includes the following below. Arithmetic Operators Arithmetic Operators: These operators are used for basic arithmetic operations such as addition, subtraction, multiplication, and division. The addition operator + can also be used for string concatenation. Examples of arithmetic operators include +, -, *, /. Addition (+)   In this example above, I have used the addition operator is used to add two or more numbers or to concatenate two or more strings. Subtraction (-) In the example above, I have used the subtraction operator is used to subtract one number from another.   Multiplication (*)   In the example above, I used the multiplication operator is used to multiply two or more numbers.   Division (/)     In the example above, I have used the division operator is used to divide one number by another.     Remainder/Modulus (%)     In