(27) Doesn't work with dot notation


I already solved it with the bracket way, then tried using dot notation. Here is the code:

 var languages = new Object();
    languages.english = 'Hello';
    languages.french = 'Bonjour';
    languages.spanish = 'Hola';
    languages.number = 1;
    for (var one_lang in languages) {

// So, lets say we are in the for loop, and for testing purposes 'one_lang" is 'english'.
When I try to print out 'languages.one_lang' I got the message that is 'undefined', which is strange.
Its same as saying 'languages.english'. Can someone explain why it doesn't work?

    console.log(one_lang); //print 'english'


//This part doesn't work anyway

if(typeof languages.one_lang === 'string') {
else {


you can leave out the else block, i dont think continue works like that, as this isn't going through a loop


When using the dot method, "one_lang" does not get resolved.
So it tries to literally get languages.one_lang, which does not exist in your object.
This would be the same as asking for languages["one_lang"], which will also not work.


boss your code won't work because of the dot notation you are not supposed to use dot notation for iteration. remember your did not creat a one_language variable as an instance of any class.
i did something like below to yur code and it worked
for (var i in languages) {

console.log(i); //print 'english'

if(typeof languages[i] === 'string') {
else {