Message from JavaScript discussions

May 2019

— I have already used the .split method to separate classes but I need to split them as when adding more classes in the classList method

Message permanent page


The function requires that all the classes to be added are grouped in a string and at the beginning of the function, check if the browser supports classList. In that case I need to separate the classes into a different string for each of them

— Wat

— Why are they joined like that?

— Just loop

— I have already tested the "final" variable, it works

— classes.trim().split(/\s+/g).forEach(class =>

— Check this

Message permanent page

— Unexpected token, expected "{" (1:43)

> 1 | classes.trim().split(/\s+/g).forEach(class => {
| ^
2 | el.classList.add(class)});

Message permanent page

— Wat

— What kind of browser are you testing this with

— The latest version of chrome