In this lesson we learned how to treat numbers and strings.
First, we learned how to store values returned from prompts, using the following commands:
- Number.parseInt(value): Transforms the value to an integer.
- Number.parseFloat(value): Transforms the value to a float.
- Number(value): Tranforms the value to the type of the number passed as argument.
After that, we learned how to parse values to string:
- String(value)
- value.toString()
We also worked with templates strings using the ` signal to delimit strings and the ${value} operand to use variables as string.
Finally, we learned some functions to treat strings and numbers:
- value.length: return the length of the string value.
- value.toUpperCase(): sets all letters of the string value to upper case.
- value.toLowerCase(): sets all letters of the string value to lower case.
- value.toFixed(*numberOfDecimalCases).replace("whatIsGoingToBeReplaced", "Replacement")
- value.toLocaleString('location', {style})
And the document.write(value) command.