Skip to content

Instantly share code, notes, and snippets.

@wesscoby
Created November 7, 2018 14:52
Show Gist options
  • Save wesscoby/c45a7238559214dabd3c581b7d8ba758 to your computer and use it in GitHub Desktop.
Save wesscoby/c45a7238559214dabd3c581b7d8ba758 to your computer and use it in GitHub Desktop.

// Question 1 const bills = [ {date: '2018-01-20', amount: '220', category: 'Electricity'}, {date: '2018-01-20', amount: '20', category: 'Gas'}, {date: '2018-02-20', amount: '120', category: 'Electricity'} ];

// Answer const getCategoryList = (inputObject) => { let categoryList = []; inputObject.forEach(value => { if (!categoryList.includes(value.category)) { categoryList.push(value.category); } }); return categoryList; };

// usage console.log(getCategoryList(bills));

// Question 2 let theString = 'ama'; for (let character of theString.toUpperCase()) { console.log(character); }

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