I am trying to write out all outerText values to an array.
This is based on a class selector
jQuery is usable my attempt is below syntax invalid e.g.
array =[];
$( ".v-captiontext" ).each(function( index )
{
array.push($( this ).outerText() )
);
});
var array = [];
$(".v-captiontext").each(function(index) {
array.push($(this).outerText());
});
is the correct syntax. Seems like you are not using any IDE. Start using one.
Firstly, the reason you have invalid syntax is because you have an extra ) in the code. If you format your code it makes it easier to spot mistakes like this.
With regard to your goal, outerText is the property of an Element object, not a jQuery object or a method. Call it on the this reference directly:
let array = [];
$(".v-captiontext").each(function() {
array.push(this.outerText);
});
Also note that you can simplify this further by using map() instead of each():
let array = $(".v-captiontext").map((i, el) => el.outerText).get();