DEV Community

Discussion on: 28 Relevant Javascript Interview Questions Part I - The first 4

Collapse
 
johnboy5358 profile image
John

This might be a relevant question to ask


/*

  Bank notes for three different currencies are stacked in five piles per
  row(represented by the money array below).

  The task is to output to the console only those rows where the currency
  is USD AND the sum of the currency values in the five piles sums to
  100.

*/

const money = [
  {id: 0, currency: 'USD', value: [10, 20, 20, (20 + 20), 10]},
  {id: 1, currency: 'EURO', value: [10, 20, 10, 10, 10]},
  {id: 2, currency: 'USD', value: [10, 20, 20, 50, 10]},
  {id: 3, currency: 'USD', value: [20, 20, 20, 20, 20]},
  {id: 4, currency: 'GBP', value: [10, 20, 20, (20 + 20), 10]},
  {id: 5, currency: 'USD', value: [10, 20, 50, 20, 20]},
  {id: 6, currency: 'EURO', value: [5, 20, (10 + 20), (20 + 20), 5]},
  {id: 7, currency: 'USD', value: [10, 20, (10 + 20), (20 + 20), 50]},
  {id: 8, currency: 'GBP', value: [10, 20, 20, 20, 10]},
  {id: 9, currency: 'USD', value: [10, 20, (10 + 20), (20 + 20), 100]},
  {id: 10, currency: 'GBP', value: [10, 20, (10 + 20), (10 + 20), 10]},
  {id: 11, currency: 'EURO', value: [10, 20, (10 + 20), (20 + 20), 10]},
]

Collapse
 
adyngom profile image
Ady Ngom

Nice thanks for the contribution. I will take a close look. I really like the wording which sounds like a good user story.
Cheers