567643e7016656be29e9b30e06c4ad61 javascript1 lab1 v2 rasb14 2018-11-14 16:39:42 v3.1.3 (2018-09-13)
Generated 2018-11-14 17:39:42 by dbwebb lab-utility v3.1.3 (2018-09-13).
The foundation of variables, numbers, strings and basic arithmetic and built in functions.
Use MDN as your reference and base to solving the exercises.
Use variables, numbers and built-in functions.
One way to round a float to a certain amount of decimals is:
Math.round(val*10000)/10000
Where val is your float number.
Create two variables, floatOne and floatTwo.
Give them the values 719.08 and 805.16.
Create a variable called result and assign to it the sum of the variables above.
Answer with the result, rounded to two decimals.
Create a variable someIntText and give it a string value of "277.521 crocodile".
Use the function parseInt() to find out the integer representation of the text.
Assign the value to your result-variable.
Answer with the result.
Use your variable someIntText.
Use the function parseFloat() to find out the float representation of the text.
Assign the value to your result-variable.
Answer with the result.
Use the method max(), in Math, to find out the highest number in the serie:
401,339,956,831
Assign the number to your result-variable.
Answer with the result.
Use the Math property PI to get the float value of ‘Pi’. Round the result to 4 decimals.
Assign the number to your result-variable.
Answer with the result.
Work with strings and find out about the built-in functions.
Create a variable called wordOne and assign the word “mouse” to it.
Add (concatenate) the number 440 to the word and answer with the resulting variable.
Use the built-in method charAt() on the word “bulldog” to return the character at a given index.
Answer with the character at index 0.
Use the built-in method toUpperCase() to transform the string:
"I am in a glass case of emotion." to uppercase.
Answer with the result.
Use the built-int property length to find out the length of the string: "bulldog".
Answer with the result.
Use the built-int method substr() to extract the last three characters of the word: "bulldog".
Answer with the result.
Solve these optional questions to earn extra points.
Create a Date object called myDate and initiate it with: "Aug 23, 1992".
Use the built-in function Date.getFullYear() to get the year from your Date object.
Answer with the result.
Create a new Date object that is equal to myDate plus 16 days.
Use Date.getDate() and answer with the day of the month.
567643e7016656be29e9b30e06c4ad61