HackerRank Loops | JS Solution
Problem
HackerRank detailed problem description can be found here.
Inputs & Outputs
/*
input {number} n
output {string} n x i = result
*/
Test Case
n = 5;
JavaScript Solution
function main() {
const n = parseInt(readLine(), 10);
if (!n || typeof n !== 'number') {
return;
}
for (let i = 1; i < 11; i++) {
console.log(`${n} x ${i} = ${n * i}`);
}
}
Resources
- Loops algorithm by HackerRank
- typeof by MDN Web Docs
- Template literals by MDN Web Docs