My Javascript function leads my console to return me :
TypeError: style is null
Here the snippet:
Rename your style
variable into styles
and then instead of having null
as your first argument when you invoke styling
, use undefined
:
const styles = {
one: 1,
two: 2,
three: 3
}
function styling(style = styles, ...ruleSetStock) {
return ruleSetStock.map(ruleSet => {
console.log(ruleSet)
return style[ruleSet]
})
}
console.log(styling(undefined, "one", "two", "three"))
// one
// two
// three
// [1, 2, 3]