Dot and Bracket Notation - JavaScript Basics

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

function harmlessRansomNote (noteText, magazineText) {
var noteArr = noteText.split(' ');
var magazineArr = magazineText.split(' ');
var magazineObj = {};

magazineArr.forEach(word => {
console.log(word);
if (!magazineObj[word]) magazineObj[word] = 0;
magazineObj[word]++;
console.log(magazineObj);
});
}

harmlessRansomNote('i i is is is is is is is a secret note for you note from a secret admirer', 'puerto rico is a place of arat wonder and excitement it has many secret waterfall locatoins tha i am an admirer of you must hike quite a distance to find the secret places as they are far from populated areas but it is wotrh the effrt a tip i have for you is to go early in the morning whan it is is not so hot out alse note note that you must wear hiking boots this is is one of the best places i have ever visited');






why this code is not work throught dot notation?
if (!magazineObj.word) magazineObj.word = 0;
magazineObj.word++;

konstantinkkk