File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
09-Data-Structure-Modern-Operators-and-Strings Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -338,3 +338,24 @@ const users = [{ name: "Eke", email: "hello@eke.com" }];
338338console . log ( users [ 0 ] ?. name ?? "User array empty" ) ;
339339
340340// 🔸Looping Objects, Keys, Values, and Entries🔸
341+ const properties = Object . keys ( openingHours ) ;
342+ console . log ( properties ) ;
343+
344+ let openStr = `We are open on ${ properties . length } days: ` ;
345+
346+ for ( const day of properties ) {
347+ openStr += `${ day } , ` ;
348+ }
349+ console . log ( openStr ) ;
350+
351+ const values = Object . values ( openingHours ) ;
352+ console . log ( values ) ;
353+
354+ // Entries Object
355+ const entries = Object . entries ( openingHours ) ;
356+ console . log ( entries ) ;
357+
358+ // [key, value]
359+ for ( const [ q , { open, close } ] of entries ) {
360+ console . log ( `On ${ q } we open at ${ open } and close at ${ close } ` ) ;
361+ }
You can’t perform that action at this time.
0 commit comments