I am facing a challenge where I need to convert a string representation of an array into a JavaScript array for the purpose of looping. The string in question is enclosed within single quotes.
Inside my JavaScript code, I have the following:
var length1 = $('.length').text(); //['2018-9-24', '2018-9-26', '2018-9-25']
console.log(length1.length) // 39 as output but I need it to be 3
The objective is to loop through each date mentioned in the array.
Any assistance on this matter would be highly appreciated.
I attempted the following:
var myArray=JSON.parse(length1); // However, this approach did not work