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

181
Vistas
reduction of complexity numbers procedure

I'm looking for a solution to my problem

if I have numbers

var first = 14:1
var next = 13:8

therefore, the console should give a result

console.log(first_result)  // 141
console.log(next_result)  // 141

and I want the numbers counted like 141 in the result to be

simply if there is an example

13:8 if both digits are the last, 3 and 8 are bigger than ten, then turn the tens and turn and insert into the previous number and leave the rest at the end

so 13:8 becomes 141

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

0

If you are starting with strings, then you just simply split the string on : to get your 2 numbers.

To get the last digit, you can simply use x % 10. Then just add the numbers and see what happens.

let value = '13:8',
    nums = value.split(':').map(Number),
    last_digits = nums.map(x => x % 10),
    // or last_digits.reduce((x,y) => x+y, 0)
    sum = last_digits[0] + last_digits[1],
    result;

if (sum > 10) {
    nums[0]++;
    nums[1] = sum - 10;  // or, probably sum % 10
}

result = nums.join('');
console.log(result);

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