2
Hello I’m having difficulty storing the value of the day that precedes the comma:
<span id="organizerContainer-date">Novembro 3, 2018</span>
I would like to store this value to do some things. If someone has done this before you could let me know what it would be like to do it using jquery ?
Hello Sergio, can you explain the logic behind
filter(Boolean)
and why not directlysplit(...)[1]
?– Isac
@Isac for the question example is not necessary, but my experience is that there are always variations in the input string. If for example there is a space before the month name, then the code would fail. Or an extra space between words/number, then it would also fail. Just as the accepted answer would also fail. So I use
.filter(Boolean)
which basically removes empty positions in the array that thesplit
creates. It’s clear? It might be interesting to add this to the answer?– Sergio
Yes I had already realized that you were removing the voids just not to see why. I think it actually makes the solution better and more robust. Thank you for the reply
– Isac