For example, if the number put in the html form was 30.1 I need to separate the 30 from the 1 in javascript thanks Ben
You need to convert it to string first, then use String.prototype.split method. For example
const value = 30.1;
const separated = `${value}`.split("."); // output will be ["30", "1"]
console.log(separated[0], separated[1]) // "30", "1"
if you want to read it as number, you can use Number()
console.log(Number(separated[0]), Number(separated[1])) // 30, 1
It's mandatory to convert number into String for split
let number = 30.1;
let convertToString = String(number);
let splitNumber = convertToString.split(".");
for(let i = 0; i < splitNumber.length; i++)
{
console.log(splitNumber[i]);
}
you should convert the number into string then using spilt methode
let num = 40.1
let value = num.toString().split('.');
console.log(value)