Skip to content

Tag: javascript

Using replace string method inside forEach

I have an array full of strings which I’d like to loop over and replace any occurrences of ‘123’ with ”. The desired result would be: [‘hello’, ‘cats’, ‘world’, ‘dogs’] Answer Use .map instead, if you can – return the .replace call …

Get HTML Table Data into Bar Chart

I’ve been messing around with some database data that I’ve imported into an HTML table. Then I decided that I needed to get that data into a bar chart. Is there a way I can do this? If so can you show me how to do so? HTML (warning code snippet doesn’t actually work here, but it does in my

Get `children` prop from component

UPDATE: For anyone learning and confused on this as I was, this page describes what’s going on — my confusion was between a React component vs React elements https://reactjs.org/docs/rendering-elements.html ORIGINAL QUESTION: The page linked below suggests the children prop is passed by default wh…

How to use for loop to sum a numbers inserted by the user?

i’m trying to create a simple project where the user is prompted to enter how many numbers he would like to add(sum). then when he click the button, a javascript will create a number of input tags equal to the number he inserted and then he will fill them with a number and click another button to calcul…

Search function .match() case sensitive

this.items is an array of objects. I am using this to search the items by the search bar, but .match() is case sensitive. For example, if I have an item called Milk, when I type milk, it won’t come up. How can I make this work for both lowercase and uppercase? Live demo I tried: but it gives me a