I have a problem with a task which i am trying to solve.
I have been set a task which most do the following;
1) On each number within the array, print out to screen (in an unordered list) each number’s array value and their associated description.
And the code is to do this task with is as follows;
var numbers = [
'1',
'2',
'3',
'4',
'5',
'6'
],
description = {
'One': 'Number one',
'Two': 'Number two',
'Three': 'Number three',
'Four': 'Number four',
'Five': 'Number five',
'Six': 'Number six'
};
Does anyone have any idea how to solve this using some sort of loop?
If you could also explain to me in comments to tell me whats happening that would be great.
Kind Regards,
B
You can assign an array of objects, each object containing a description that corresponds to the index value of that object: