How to append int to int in JavaScript

2 Answers

0 votes
function concatenate(x, y) {
    let pow = 10;
     
    while (y >= pow) {
        pow *= 10;
    }
     
    return x * pow + y;
}
         
let a = 14;
let b = 938;
 
a = concatenate(a, b);
 
console.log(a);
 
 
 
 
/*
run:
 
14938
 
*/

 



answered Oct 19, 2023 by avibootz
0 votes
let a = 14;
let b = 938;
 
a = parseInt("" + a + b);
 
console.log(typeof a);
console.log(a);
 
 
 
 
/*
run:
 
"number"
14938
 
*/

 



answered Oct 19, 2023 by avibootz

Related questions

1 answer 156 views
2 answers 112 views
2 answers 192 views
1 answer 181 views
1 answer 181 views
1 answer 172 views
...