preserveDecimal(n) preserves n's decimals (it parses n as a floating point number) and returns the parsed number:
Error: Expected '2.222' to be 2.222
I am new to coding and I have been stuck on this assignment for a while.
preserveDecimal(n) preserves n's decimals (it parses n as a floating point number) and returns the parsed number:
Error: Expected '2.222' to be 2.222
I am new to coding and I have been stuck on this assignment for a while.
Use the inbuilt function to pass your string to a float. It will be parsed if the string is a valid float.
let x = parseFloat(string)
Refer https://www.w3schools.com/jsref/jsref_parsefloat.asp for more information