DEV Community

Cover image for Day 5: Loops
Vijay Chauhan
Vijay Chauhan

Posted on

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

Top comments (0)