How to remove the N digit from a number in Node.js

1 Answer

0 votes
function remove_the_N_digit(num, N) {
    let str = num.toString();
     
    str = str.substring(0, N) + str.substring(N + 1);
     
    return parseInt(str);
}
         
let num = 8706175;
 
num = remove_the_N_digit(num, 3);
 
console.log(num);


 
 
/*
run:
    
870175
    
*/

 



answered Jan 18, 2024 by avibootz

Related questions

1 answer 135 views
1 answer 103 views
1 answer 106 views
1 answer 127 views
...