How to Check if string contains commas? [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Fetching an CSV file using ajax request. Now, I want separate CSV's into array of values and render an list of all values.

You can use split which will turn a string into an array.
let csv = "Chelsea,Liverpool,Man United";
let splitCSV = csv.split(",");
console.log(splitCSV);

Related

I need to extract the data from the title which is in a string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
I want to take the data from the title in string
so how can I take the data that's string and take the string that's in the title
data: "[{\"_id\":\"63aada6d081cf22ce63a5c46\",\"title\":\"Hamko 1000VA Pure Sine Wave Home IPS \"
Something like :
data.split("title")[1]

How can I loop over this data of nested objects? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
I want to display the filters.label on the DOM. I've tried multiple loops with multiple combinations with no success.
This is a fetch call and I have to loop over the response.json().
You can try this:
const filters = response.data.collectionByHandle.products.filters;
for (var filter of filters) {
// Your code here
}

How to count specific items in array [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I've got this array in my jquery Script :
I want to count all items inside my array called div.item.bloc-membre
Right now I have this code that returns me 75
console.log($(response).length);
Thanks for your help !
Using filter
console.log($(response).filter("div.item.bloc-membre").length);

RegEx string - code with JavaScript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
If I have a string in this format:
RED-MPWMC-40486655646-024
How can I extract MPWMC from this string with javascript?
No need of regex here. Just split it using - and access the array element with index=1.
var str = "RED-MPWMC-40486655646-024";
console.log(str.split("-")[1]);

external json to acces in javascript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
How can I access categories.name_category in Javascript? Everything is working for the AJAX call to the REST API:
I tried to do like this but its not working:
I use Moustache framework
categories is an array of objects, so you need to use {{categories[0].name_category}} - assuming you only want the first value.

Categories