I have the following string:
apple, banana, orange
and I want to get only the first word of that string and before the first comma:
In this example it's apple
For that, I have done the below:
var string = "apple, banana, orange";
var splitedArray = string.split(',');
console.log('This should show it ', splitedArray[0])
It works fine, but I am wondering if there exists a better way to it.