I'm new to JS. If I add a semicolon like this ${this.name} is friends with ${el}
; I'll get an error "Uncaught SyntaxError: missing ) after argument list". May I know why? Since in ES5, I can use semicolon like return this.name + ' is friends with ' +el;
Thank you so much!
function Person(name) {
this.name = name;
}
ES6
Person.prototype.myFriends5 = function(friends) {
var arr = friends.map((el) =>
`${this.name} is friends with ${el}`
);
console.log(arr);
}
var friends = ['Bob', 'Jane', 'Mark'];
new Person('John').myFriends5(friends);