<h1>Graduate Assignment</h1>
<h2>Proving my understanding : The incrementation operator</h2>
<ol>
<li>
How it works: the incrementation operator allows you to increment 1 to a number using a simple syntax. On the other hand the dcrementation is for substracting 1.</li>
<li>
The incrementation operator can also be before the variable
</li>
<li>
The difference between before and after the variable is the prority of the operation and it is important if you're trying to get the result of the incrementation.
</li>
</ol>
JavaScript
"use strict";
// Code for 1
var ourNumber = 0;
ourNumber++;
alert("1) ourNumber = "+ ourNumber); // ourNumber is now 1
ourNumber--;
alert("ourNumber = "+ ourNumber); // ourNomber return to 0
// Code for 2
var ourFirstNumber = 0;
var ourSecondNumber = 0;
ourFirstNumber++;
++ourSecondNumber;
alert("2) ourFirstNumber = "+ ourFirstNumber); // ourFirstNumber is 1
alert("ourSecondNumber = "+ ourSecondNumber); // ourSecondNumber is also 1
// Code for 3
// Here the ++OurNumber return the incremented value
var ourNumber = 0;
var OurOutput = ++ourNumber;
alert("3) ourNumber = "+ ourNumber); // 1
alert("OurOutput ="+ OurOutput); // 1
// But here ourNumber++ return the non incremented value
var ourNumber = 0;
var OurOutput = ourNumber++;
alert("ourNumber = "+ ourNumber); // 1
alert("OurOutput ="+ OurOutput); // 0
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.