R
R
Roman2019-12-03 08:42:37
JavaScript
Roman, 2019-12-03 08:42:37

alert doesn't work, why?

Hello. I'm learning JS. The question is, why doesn't the alert work? Even if an arbitrary message is written, the script does not reach alert, something is wrong in the array.

var lang = 'ru';
var day = 1;
var arr = {'ru': [1:'Пн', 2:'Вт', 3:'Ср', 4:'Чт', 5:'Пт', 6:'Сб', 7:'Вс'],
    'en': [1:'Mon', 2:'Tues', 3:'Wedn', 4:'Thur', 5: 'Fri', 6:'Sutur', 7:'Sun']
    };
alert(arr[lang]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WStanley, 2019-12-03
@yagyar001

In arrays, remove indices Either the object

let obj = {
   'ru': {1:'Пн', 2:'Вт', 3:'Ср', 4:'Чт', 5:'Пт', 6:'Сб', 7:'Вс'},
   'en': {1:'Mon', 2:'Tues', 3:'Wedn', 4:'Thur', 5: 'Fri', 6:'Sutur', 7:'Sun'}
}
console.log(obj["en"][1])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question