Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

83
Vistas
I need to know how to read an input from a html form in JavaScript and separate the digits after the decimal point

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

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

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
about 4 years ago · Juan Pablo Isaza Denunciar

0

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]);
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

you should convert the number into string then using spilt methode

let num = 40.1
let value = num.toString().split('.');
console.log(value)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda