Fetch all H1 and H2 text and push into an array

[av_codeblock wrapper_element=” wrapper_element_attributes=” codeblock_type=” av_uid=’av-lczzquub’ custom_class=”]

Get all H1 and H2 heading content and text push to array

var headingOne = []; 
var headingTwo = []; 
var bothHeading = [];
var hTwoSeprate = []; 

headingOne.push(jQuery('h1').text()); 


headingTwo.push(jQuery('h2')); 

console.log(headingTwo[0].length);

var allSHeading = []; 

for(i = 0; i < headingTwo[0].length; i++){
    console.log(headingTwo[0][i].innerHTML);
    allSHeading.push(headingTwo[0][i].innerHTML);
}

bothHeading = [...headingOne, ...allSHeading]; 

console.log(bothHeading);

[/av_codeblock]