Skip to content

Commit a56f742

Browse files
committed
pattern ques update
1 parent ac64578 commit a56f742

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

js_notes/patternQ.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ Add a new line after each row
208208
209209
*/
210210
let rows = 5;
211-
for(let i=1;i<=rows;i++){
212-
let pattern = "";
213-
for(let j=1;j<=rows;j++){
214-
if(i==1||i==rows||j==1||j==rows){
211+
for(let i=1;i<=rows;i++){ //outerloop for no.of rows
212+
let pattern = ""; //prints new line for each outerloop iteration
213+
for(let j=1;j<=rows;j++){ //innerloop for columns
214+
if(i==1||i==rows||j==1||j==rows){ //for row 1 and 5 and column 1 and 5 print stars else print space.
215215
pattern += "*";
216216
}
217217
else{
@@ -220,4 +220,16 @@ for(let i=1;i<=rows;i++){
220220
}
221221

222222
console.log(pattern);
223-
}
223+
}
224+
225+
const readline = require('readline');
226+
227+
const rl = readline.createInterface({
228+
input: process.stdin,
229+
output: process.stdout
230+
});
231+
232+
rl.question("Enter something: ", function(userInput) {
233+
console.log("You entered:", userInput);
234+
rl.close();
235+
});

0 commit comments

Comments
 (0)