My Javascript function leads my console to return me :
TypeError: style is null
Here the snippet:
Two things you need to update
please see the updated code
let defaultStyle = {
one: 1,
two: 2,
three: 3
}
function styling(style = defaultStyle, ...ruleSetStock) {
return ruleSetStock.map(ruleSet => {
console.log(ruleSet)
return style[ruleSet]
})
}
console.log(styling(undefined, "one", "two", "three"))
you can write the above snippet in much more cleaner way using es6
see the below snippet
const defaultStyle = {
one: 1,
two: 2,
three: 3
}
const styling = (style = defaultStyle, ...ruleSetStock) => ruleSetStock.map(ruleSet => {
return style[ruleSet]
})
console.log(styling(undefined, "one", "two", "three"))