lab.md

1 lines ASCII Unix (LF)
1
Lab questions
==============================

1. Create a variable, named "firstWord", that holds the word "Javascript".
Create a second variable, named "secondWord", that holds the word "rocks!".
Create a third variable, named "bothWords", and put together firstWord and secondWord with a space between the words.
Print out the result.

2. Create a variable called "numberOne" and give it the value 10. Create another variable called "numberTwo" and give it the value 5. Create a third variable called "sum" and assign to it the sum of the first two variables.
Print out the result.

3. You can also create several variables straight away with a comma-separation. Create the variables: wordOne, wordTwo, wordThree, wordFour and wordFive. Assign the words: "My name is John Doe" to the varibles by assigning the values with comma-separation.
Print out the result with space between the words.  

4. A good thing is that we do not need to use one variable for each word. Create a variable called "sentence" and assign to it the text: "This was convenient" and print it out.

5. Use a for-loop to print out the numbers 1 to 10.

6. Use a for-loop to print out the numbers 10 to 1.

7. Use a while-loop to print out the numbers 1 to 10.

8. Use a while-loop to print out the numbers 10 to 1.

9. Use if else statements to print out "yes" if 10 is larger than 5, else print out "no".

10. You can compare variables in different ways. Compare the number 10 and a string that holds 10 ("10"). Use double equals when comparing (==). Use if else statements to print out "yes" if 10 equals "10", else print out "no".

11. As you saw in question 10, they are equal. This is because the double equal (==), do a type conversion of the variables. To get around that, you can use a triple equal (===). Then there is no type conversion done and the compare is made on both value and type. Use if else statements to print out "yes" if 10 equals "10", else print out "no". Use triple equals (===).

------------------------------

2014-06-03 (Zingo89) PA1 First try.