-
Notifications
You must be signed in to change notification settings - Fork 0
/
comparingElements.js
22 lines (21 loc) · 969 Bytes
/
comparingElements.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var testArray = [0, 1, 1, "1", 3, "311"];
for (var arrayPosition = 0;
arrayPosition < testArray.length - 1; arrayPosition++)
{
var currentElement = testArray[arrayPosition];
var nextElement = testArray[arrayPosition + 1];
console.log("Testing " + currentElement + " and " + nextElement + "(greater than): " + (currentElement > nextElement));
console.log("Testing " + currentElement + " and " + nextElement + "(less than or equal to): " + (currentElement <= nextElement));
if (currentElement == nextElement)
{
console.log("Testing " + currentElement + " and " + nextElement + "(strictly equal to): " + (currentElement === nextElement));
if (currentElement !== nextElement)
{
console.log(currentElement + " is " + typeof(currentElement));
console.log(nextElement + " is " + typeof(nextElement));
}
} else
{
console.log("Testing " + currentElement + " and " + nextElement + "(equal to): false");
}
}