mardi 7 septembre 2021

program for printing 'Square' pattern in javascript

as i have tried printing 3*5 box *(star) pattern program but not able to get it properly can any one guide me mistakes if and help to rectify .TIA below is the code in javascript:

// Getting input via STDIN
const readline = require("readline");

const inp = readline.createInterface({
  input: process.stdin
});

const userInput = [];

inp.on("line", (data) => {
  userInput.push(data);
});

inp.on("close", () => {
  //start-here
var i,j,a=3,b=5;
for(i=1;i<=a;i++)
{
    for(j=1;j<=b;j++)
    {
        console.log("*");
    }

    console.log("\n");

}

  //end-here
});

output: * * * * *

* * * * *

* * * * *

need to get like this output:




Aucun commentaire:

Enregistrer un commentaire