samedi 3 avril 2021

Node.js Pattern

var readline=require("readline-sync");
var n=parseInt(readline.question());

for (var i=1;i<=n;i++){
  var str="";
for (var j=1;j<=i;j++){
str+="*";
  console.log(str);

}console.log();

}

Plesse tell me where I am doing wrong . I want to print a pattern for

*
**
***
****
***** 

Also please tell me where I can do improvements. Thanks !

Aucun commentaire:

Enregistrer un commentaire