Following Colt Steele’se bootcamp i finnished lession about Movie Database using array’s and objects. I need a help with why did he use
result += movie.rating + " stars";
console.log(result);
after the if statement? Now my biggest confusion part is why did he have to use ```result += movie.rating + " stars"; when result is a "You have " string?
Here’s a code:
var movies = [
{ title: "The Burges",
rating: 5,
hasWatched: true
},
{ title: "Frozen",
rating: 4.5,
hasWatched: false
}
]
movies.forEach(function (movie) {
var result = "You have ";
if (movies.hasWatched) {
result += "watched";
} else {
result += "not watched";
}
result += "\"" + movie.title + "\" - ";
result += movie.rating + " stars";
console.log(result);
});