My textfield has this value:
"1
2 2
3
4 4
5 a
6
7
8
"
When I split it by “\n” I get:
["1", "2 2", "3", "4 4", "5 a", "6", "7", "8", ""]
I want to delete the last element. I’m doing this:
$('#textArrayId').val().replace($('#textArrayId').val().split("\n")[$('#textArrayId').val().split("\n").length - 1], "")
And I can’t get it to delete. What to do?
I want to do this with string operations, not array operations.
To remove the last line, use this
Or if you want to remove the last line without whitespace:
To remove the last element of an array, use this expression to receive all elements but the last: