How to get the second digit of a number in TypeScript

1 Answer

0 votes
const num = 72984;

const secondDigit_string = String(num)[1];

const secondDigit_number = Number(secondDigit_string);

console.log(secondDigit_number); 


  
  
  
  
/*
run:
  
2
  
*/

 



answered Jun 17, 2022 by avibootz

Related questions

1 answer 107 views
2 answers 110 views
2 answers 165 views
1 answer 106 views
2 answers 152 views
...