Day 5: Loops

vijaychauhanssn

Vijay Chauhan

Posted on June 3, 2021

Day 5: Loops
   'use strict';

   process.stdin.resume();
   process.stdin.setEncoding('utf-8');

   let inputString = '';
  let currentLine = 0;

  process.stdin.on('data', function(inputStdin) {
  inputString += inputStdin;
  });

  process.stdin.on('end', function() {
  inputString = inputString.split('\n');

 main();
 });

function readLine() {
 return inputString[currentLine++];
}


 function main() {
 const n = parseInt(readLine().trim(), 10);
 for (let i = 1; i<=10; i += 1){
    console.log(`${n} x ${i} = ${n * i}`)
 }
 }
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
vijaychauhanssn
Vijay Chauhan

Posted on June 3, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related