You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30-Days-Of-JavaScript/Exercise-Solutions/days/13_day_consol_objmth.md

2.0 KiB

Day 13 - Console Object Methods

Exercise:Solutions

Home | << Day 12 | Day 14 >>

Exercise Solutions

Exercises Level 1

  1. Display the countries array as a table
// app.js
const countries = ['Norway', 'Sweden','England','Iceland']
console.table(countries)

  1. Display the countries object as a table
// app.js
const countries ={
    countri: 'Germany',
    popolation: 564654,
    lamgue: 'German'
}
console.table(countries)
    
  1. Use console.group() to group logs
// app.js

const names = ['Asabeneh', 'Brook', 'David', 'John']
const countries = [
  ['Finland', 'Helsinki'],
  ['Sweden', 'Stockholm'],
  ['Norway', 'Oslo']
]
const user = {
  name: 'Asabeneh',
  title: 'Programmer',
  country: 'Finland',
  city: 'Helsinki',
  age: 250
}
const users = [
  {
    name: 'Asabeneh',
    title: 'Programmer',
    country: 'Finland',
    city: 'Helsinki',
    age: 250
  },
  {
    name: 'Eyob',
    title: 'Teacher',
    country: 'Sweden',
    city: 'London',
    age: 25
  },
  {
    name: 'Asab',
    title: 'Instructor',
    country: 'Norway',
    city: 'Oslo',
    age: 22
  },
  {
    name: 'Matias',
    title: 'Developer',
    country: 'Denmark',
    city: 'Copenhagen',
    age: 28
  }
]

console.group('names')
console.log(names)
console.groupEnd()

console.group('countries')
console.log(countries)
console.groupEnd()

console.group('user')
console.log(user)
console.groupEnd()

Exercises Level 2

  1. 10 > 2 * 10 use console.assert()
  2. Write a warning message using console.warn()
  3. Write an error message using console.error()

Exercises Level 3

  1. Check the speed difference among the following loops: while, for, for of, forEach

Home | << Day 12 | Day 14 >>