0

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.

costaparas
  • 5,047
  • 11
  • 16
  • 26
Jsk8
  • 1

1 Answers1

0

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