i am watching currently a course and the teacher is using a lot of the $-sign:
var _ = require('underscore');
const weapons = ['candlestick', 'lead pipe', 'revolver'];
const makeBroken = function(item){
return `broken ${item}`;
};
const brokenWeapons = _.map(weapons, makeBroken);
console.log(brokenWeapons);
I am using instead this variant:
var _ = require('underscore');
const weapons = ["candlestick", "lead pipe", "revovler"]
function makeBroken(item) {
return 'broken ' + item;
}
const brokenWeapons = _.map(weapons, makeBroken)
console.log(brokenWeapons);
But when i try to modify my version to "her" style, it doesnt work:
var _ = require('underscore');
const weapons = ["candlestick", "lead pipe", "revovler"]
function makeBroken(item) {
return 'broken ${item}';
}
const brokenWeapons = _.map(weapons, makeBroken)
The first and second give me this out and is working: [ 'broken candlestick', 'broken lead pipe', 'broken revovler' ] The third give me this output and is not working: [ 'broken ${item}', 'broken ${item}', 'broken ${item}' ]
My questions: Is the variant of the teacher better with the ${}-method or it is only a matter of taste? Why is the modified variant (the third) not working?
Thanks a lot for the help of the stupid questions :D