Skip to content

Instantly share code, notes, and snippets.

@max-programming
Last active August 19, 2020 12:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save max-programming/ed24705fd9bc26d349b849cb226d785a to your computer and use it in GitHub Desktop.
The Assignment / Task for Destructuring

Destructuring Assignment / Task

A task/challenge from my video on Destructring in JavaScript

  • Create an array of objects
  • Each object should contain the data of a browser
  • Store the "company", "name" and "marketShare" in variables for any random item in the array every 2 seconds
  • log "{company} developed {name} which holds {marketShare} of the Market Share" to the console

To get other browser market shares: Browser Market Shares


Example Data:

const browsers = [
  {
    name: "Firefox",
    company: "Mozilla",
    marketShare: "8.01%",
  },
  {
    name: "Chrome",
    company: "Google",
    marketShare: "68.26%",
  },
  {
    name: "Edge",
    company: "Microsoft",
    marketShare: "6.67%",
  },
  {
    name: "Opera",
    company: "Opera Software",
    marketShare: "1.31%",
  },
];

Hint: use Math.floor(Math.random() * 4) and store it in a variable to get a random number

Hint: use setInterval to repeat the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment