I know how to split a value using deliminators. I also know how to slice a value to remove the last couple chars. I need to combine these now, which is the part I can’t figure out.
$("#product").val(value.split('|')[0]);
How would I add slice(0,-1) to this function above? I want it to first split, then slice.
So the result would be everything before the ‘|’ and minus one char
Solved:
$("#product").val(value.split('|')[0].slice(0, -1))
You mean slice the 1st element from array?
Try below,