Mainly answering questions for reflection and homework.
- Type is a way to represent the data in computer memory. It is useful in writing programs as it can be keep in the way as we want efficiently.
- The following operation produces the given result 115 * 4 - 4 + 88 / 2 = 500 as multiplication and division are calculating first before addition and subtraction. After multiplication and division, the equation will be 460 - 4 + 44.
- A backslash character in a String is to indicate the next character is special, escape character.
- Dear grandma, values are people, variables are house, and control flow is road that moving people from one house to another house.
- Functions are groups of code that can be used whenever we want. We need them whenever we want to use it in many places. It is to reduce man made mistake and our life easy.
It is true. As (false || true) && !(false && true).
Write a program that calculates and shows the value of 210 (2 to the 10th power).
With some slight modifications, the solution to the previous exercise can be made to draw a triangle.
Rewrite the solutions of the previous two exercises to use for instead of while.
From Exercises 2.3
From Exercises 2.4
Write a program to ask yourself, using prompt, what the value of 2 + 2 is. If the answer is "4", use alert to say something praising. If it is "3" or "5", say "Almost!". In other cases, say something mean.
Add a while and optionally a break to your solution for the previous exercise, so that it keeps repeating the question until a correct answer is given.
Write a function called absolute, which returns the absolute value of the number it is given as its argument. The absolute value of a negative number is the positive version of that same number, and the absolute value of a positive number (or zero) is that number itself.
Write a function greaterThan, which takes one argument, a number, and returns a function that represents a test. When this returned function is called with a single number as argument, it returns a boolean: true if the given number is greater than the number that was used to create the test function, and false otherwise.