How to get the second digit of a number in Node.js

1 Answer

0 votes
const num = 79812;

const secondDigit_string = String(num)[1];

const secondDigit_number = Number(secondDigit_string);

console.log(secondDigit_number); 


  
  
  
  
/*
run:
  
9
  
*/

 



answered Jun 17, 2022 by avibootz

Related questions

1 answer 148 views
2 answers 260 views
1 answer 111 views
2 answers 149 views
...