Skip to content

Tag: javascript

React – how to display all products using dropdown?

First time trying to do this so please bear with me. I’m using a dropdown to filter product data from a local JSON file based on category. The code below does filter and display the products based on category when a user selects a category. However I’d like to show all of the products on load befo…

Reducer function for a nested array with conditions

I’m struggling to write a reducer function for the nested object that I have. queryResult can have many Parents. Every Parent has items, and every item has subitems with their .ids. How to write a reducer that would reduce the queryResult by taking in the parentId and the itemId and returning the array …

Puppeter delete node inside element

I want to scrape a page with some news inside. Here it’s an HTML simplified version of what I have : I want to get the author and text body of each news, without the blockquote part. So I wrote this code : It works well, but I don’t know how to remove the blockquote part of the “news-body&#8…

Regex match any characters in string, up until next match

I have this string: title: one description: two and want to split it into groups like [title: one, description: two] this was my attempt, but it only captures up to the : and 1 space after, it does not include the text after it, which I want to include all of, up until the second match. Answer Split on a

Get the css definition of an element

Is there a fast way to retrieve the CSS width definition (or any other CSS attribute) of an element? Notes I need to know the actual definition, like 80% or 42vw, and NOT the calculated pixel dimension. The width might be set on different CSS selectors, as illustrated in the code below Here is a sample of the…