There is an array with text for example "332 + 21" and I need to break it into two pieces, that is, what would be the measured A = 332 and B = 21. How can this be done in jQuery?
- How does an array with text look and where does jQuery come in? - Grundy
|
2 answers
var c = "332+21".split("+"); var a, b; a = c[0]; b = c[1]; |
let [a, b] = "332+21".split('+').map(e => +e); console.info(a, b); And forget jQuery already!
At least until you learn how to use normal JS .
- at least old then to study, not new)) - Jean-Claude
- @ Jean-Claude, Why learn the old when the new has already passed from the threshold to the living room and sat down with mulled wine in a chair? - user207618
- there is more information, but what about the fact that not all browsers support? I’d learn a language here, but not sculpt cross-browser compatibility)) - Jean-Claude
- @ Jean-Claude, now normal people write like white people, and transpiler does it the old way. Black people continue to suffer with the old code. - user207618
|