This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

John McSweeney - picture detail

John McSweeney

May 16, 2008, 7:34 am

M150 Data, Computing and Information

JavaScript Boolean Conditions

 

This question tests your knowledge of using Boolean conditions in conjunction with an if else statement.

JavaScript uses Unicode values of characters for comparison of strings. The value of 'A' is 65, 'Z' is 90 and 'a' is 97. The interpreter will compare the initial characters of the two strings; if each compared character is different the interpeter will be able to return true or false, otherwise it moves along and checks the next pair of characters and so on.

Q5.
i)
Complete this snippet of code by supplying a Boolean condition so that the message
Antelope is before Zebra
is displayed.

var a = 'Antelope';
var b ='Zebra';
if ---- code omitted ----
{
  document.write('Antelope is before Zebra' + '<br>');
}
else
{
  document.write('Zebra is before Antelope' + '<br>');
}

ii)
Complete this snippet of code by supplying a Boolean condition so that the message
antelope is before Zebra
is displayed.

var a = 'antelope';
var b ='Zebra';
if ---- code omitted ----
{
  document.write('antelope is before Zebra' + '<br>');
}
else
{
  document.write('Zebra is before antelope' + '<br>');
}

Link to answer for Q5. Left click and a new window will open

 

Next page » A password problem

Previous page « Numbers