What does the following code echo out:
|
1 2 3 4 5 |
if('ORANGE' > 'apple') {
echo 'orange';
} else {
echo 'apple';
} |
…
…
…
…
…
…
ANSWER:
|
1 |
apple |
The values are converted based on the ASCII alphabet, in which uppercase letters come before lowercase letters, and thus are assigned a lower value than the lowercase letters. This means that the word ‘apple’ is assigned a higher value than the word ‘ORANGE’ because of the case-sensitivity, making ‘apple’ greater than ‘ORANGE.’ When we change ‘ORANGE’ to lowercase, the otherwise same code would return ‘orange.’



