How to append int to int in Node.js

2 Answers

0 votes
function concatenate(x, y) {
    let pow = 10;
    
    while (y >= pow) {
        pow *= 10;
    }
    
    return x * pow + y;
}
        
let a = 12;
let b = 938;

a = concatenate(a, b);

console.log(a);




/*
run:

12938

*/

 



answered Oct 19, 2023 by avibootz
0 votes
let a = 12;
let b = 938;

a = parseInt("" + a + b);

console.log(typeof a);
console.log(a);




/*
run:

number
12938

*/

 



answered Oct 19, 2023 by avibootz

Related questions

1 answer 104 views
1 answer 104 views
3 answers 240 views
1 answer 129 views
1 answer 193 views
1 answer 248 views
1 answer 219 views
...