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 136 views
2 answers 229 views
1 answer 99 views
2 answers 134 views
...