Posts

Showing posts with the label Learnings

JavaScript for Beginners - Functions (P: IX)

Image
Functions A JavaScript function is a block of code designed to perform a particular task.   The main advantages of using a function; -           Re-Use - define the code once and can re-use many times. -           Use the same code many times with different arguments, to produce different results Note: A JavaScript function is executed when “something” invokes or call it. Defining a function To define a function, use the “ function ” keyword, followed by a name , followed by a set of parentheses (). Calling a function To execute the function, you need to call it. To call a function, start with the name of the function, then follow it with the arguments in parenthesis.   Note: Always remember to end the statement with a semicolon after calling the function. Once the function is defined JavaScript allows you to call it as many times as you want to.

JavaScript for Beginners - Basic Operators (P: VII)

Image
  Math Operators Arithmetic operators perform arithmetic functions on numbers (literals or variables) Operator Description Example + Addition 50 + 5 = 55 -             Subtraction 20 -10 = 10 * Multiplication 40 * 2 = 80 / Division 20 / 4 = 5 % Modules 56 % 3 = 2 ++ Increment var x = 10; x++, Now x = 11 -- Decrement var x = 10; x--, Now x = 9   Addition In the example below, the addition operator is used to determine the sum of two numbers You can add as many numbers or variables together as you want or need to Multiplication The multiplication operator (*) multiplies one number by the other. Division The / operator is used to perform division operations: The Modules Modules (%) operator returns the division reminder (what is lef