Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!