GoConqr has a new look! Let us know what you think.

Module 8 of 10 · Media

Telephone Country Problem

Kostas Diakogiannis

Telephone Country Problem

ES-4 Telephone country Problem

Given that you have this data structure:

let telephoneData = [
  {countryCode: '0030', country: 'Greece'},
  {countryCode: '0039', country: 'Italy'},
  {countryCode: '00972', country: 'Israel'},
  {countryCode: '0007', country: 'Russia'},
  {countryCode: '0044', country: 'United Kingdom'},
  {countryCode: '0001', country: 'United States'},
  {countryCode: '00963', country: 'Syria'},
  {countryCode: '0029', country: 'Belgium'},
  {countryCode: '0031', country: 'Holland'},
  {countryCode: '0049', country: 'Germany'}
]

 

Write an arrow function that accepts a string (a country code from the array above) and returns the country itself. 

Bonus: Try to accomplish this result without using any if statements, switch cases or ternary operators. You can use of course loops and any known array function. Maybe you will find the 'find' array method documentation below very useful in order to achieve this.

In a nutshell the Array's find method accepts a function (like map, forEach, filter or reduce) and loops through each element until it finds the first match given the specified condition inside the testing function. If it finds it returns the element itself, otherwise returns undefined. Find more about this method by clicking the link below.

 

The find function

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?