Skip to content

Tag: arrays

How to replace text with a random array element?

I am trying to replace text with a random element in my array. When the user clicks on the text itself, the word should change to one of the elements in my array. I am having trouble with the function that lets me do so. I have text and wrapped span tags (named “hare”) around words that I want to

Flatten objects in array

Hey folks I am getting an array of objects from a response. I need to flatten all of the students objects to simply studentName but not certain how. Any help would be greatly appreciated. Example Array: What I am trying to do: Answer You can create and return a new array of result using map as: