gistlib
To get every 7th digit in an integer in JavaScript, you can follow this approach:
Here's the code for the same:
index.tsxlet num = 1234567890123456; let numString = String(num); let seventhDigits = []; for(let i=0; i<numString.length; i++) { if((i+1)%7 === 0){ seventhDigits.push(numString[i]); } } console.log(seventhDigits); // Output: ["7", "4"] 247 chars14 lines
let num = 1234567890123456; let numString = String(num); let seventhDigits = []; for(let i=0; i<numString.length; i++) { if((i+1)%7 === 0){ seventhDigits.push(numString[i]); } } console.log(seventhDigits); // Output: ["7", "4"]
gistlibby LogSnag