JavaScript If…Else Statements

Conditional statements are used to perform different actions based on different conditions. Conditional Statements Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. In JavaScript we have the following conditional statements: Use if to specify a block of code to […]

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task. A JavaScript function is executed when “something” invokes it (calls it). Example function myFunction(p1, p2) { return p1 * p2;              // The function returns the product of p1 and p2 } Try it Yourself » JavaScript Function Syntax A JavaScript function is defined […]