Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda