Create a function that will take an array of names, and filter them into two new objects. One with names A - M and the other with names N - Z, with the names as keys and an empty string as their values. Then return a new array that contains both these objects.
You can use this array for testing if you like:
[ 'Sam',
'Sara',
'Alice',
'Wyona',
'Bob',
'Chelsea',
'Deborah',
'Katherine',
'Tyler',
'Joel',
'Blaine',
'Rebecca',
'Elvis',
'Jules',
'Flo',
'Wannita',
'Thema Lou',
'Andy',
'Barney',
'Otis',
'Helen',
'Jim',
'Dwight',
'Pam',
'Michael',
'Phyllis',
'Stanley',
'Meredith',
'Kevin',
'Angela',
'Ryan',
'Kelly',
'Karen' ]
This should be the result:
[ { Alice: '',
Bob: '',
Chelsea: '',
Deborah: '',
Katherine: '',
Joel: '',
Blaine: '',
Elvis: '',
Jules: '',
Flo: '',
Andy: '',
Barney: '',
Helen: '',
Jim: '',
Dwight: '',
Michael: '',
Meredith: '',
Kevin: '',
Angela: '',
Kelly: '',
Karen: '' },
{ Sam: '',
Sara: '',
Wyona: '',
Tyler: '',
Rebecca: '',
Wannita: '',
'Thema Lou': '',
Otis: '',
Pam: '',
Phyllis: '',
Stanley: '',
Ryan: '' } ]
Hint : you'll want to use some Regexp here, for example, /[a-m]/i
No comments:
Post a Comment