File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -208,10 +208,10 @@ Add a new line after each row
208
208
209
209
*/
210
210
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.
215
215
pattern += "*" ;
216
216
}
217
217
else {
@@ -220,4 +220,16 @@ for(let i=1;i<=rows;i++){
220
220
}
221
221
222
222
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments