View sourcecode

The following files exists in this folder. Click to view.

exercise.js

1 lines ASCII Unix (LF)
1
/**
 * Question 1
 **/
 var firstWord = "Javascript";
 var secondWord = "rocks!";
 var bothWords = firstWord + ' ' + secondWord;
 
 document.writeln(bothWords);

 document.writeln('<br>');

/**
 * Question 2
 **/
 var numberOne = 10;
 var numberTwo = 5;
 var sum = numberOne + numberTwo;

 document.writeln(sum);

 document.writeln('<br>');

/**
 * Question 3
 **/
 var wordOne = "My", wordTwo = "name", wordThree = "is", wordFour = "John", wordFive = "Doe";

 document.writeln(wordOne + ' ' + wordTwo + ' ' +  wordThree + ' ' +  wordFour + ' ' +  wordFive);

 document.writeln('<br>');

/**
 * Question 4
 **/
 var sentence = "This was convenient";

 document.writeln(sentence);

 document.writeln('<br>');

/**
 * Question 5
 **/
 for(var i = 1; i < 11; i++) {
    document.writeln(i);
 }

 document.writeln('<br>');

 /**
  * Question 6
  **/
 for(var i = 10; i > 0; i--) {
    document.writeln(i);
 }
 
 document.writeln('<br>');
 
 /**
  * Question 7
  **/
 var j = 1;
 while(j < 11) {
    document.writeln(j);
    j++;
 }
 
 document.writeln('<br>');
 
/**
 * Question 8
 **/
 var k = 10;
 while(k > 0) {
    document.writeln(k);
    k--;
 }

 document.writeln('<br>');

/**
 * Question 9
 **/
 if(10 > 5) {
    document.writeln('yes');
 } 
 else {
    document.writeln('no');
 }

 document.writeln('<br>');

/**
 * Question 10
 **/
 if(10 == '10') {
    document.writeln('yes');
 } 
 else {
    document.writeln('no');
 }

 document.writeln('<br>');

/**
 * Question 11
 **/
 if(10 === '10') {
    document.writeln('yes');
 } 
 else {
    document.writeln('no');
 }

 document.writeln('<br>');