0

Hi Guys,

Im working on a learning for fun project but now I'm stuck and I have googled my fingers off for a solution.

The scenario is this, I want to display an array of strings, word for word in the same space:

I can upload a text file and populate an array where each word becomes an array object. I have successfully printed the whole array to a div.

Now, I want to take the Array of strings and display each word from the array in the same field. I want it to work like a gif where each picture is a word from the array.

I can probably go with a foreach loop with a callbackfunction. It might work with a loop and a if statement where I check if the word is shown and if accepted remove and run the same if statement again.

Well this is where I've got stuck, what should I look in to so that I can figure this one out?

How would you do it? :)

Stay safe!

3
  • 3
    Post the code you've tried! Commented Apr 20, 2017 at 9:00
  • 1
    Are you saying you have an array of words and you want to display one word at a time with a delay between each one? If so, you can't do it with a simple loop because the browser won't repaint the screen until after the JS finishes running. Take a look at this question. (Is the background info about the words coming from a file relevant to what you're asking?) Commented Apr 20, 2017 at 9:06
  • Thanks nnnnnn I have been on the wrong side of the internet in my searches. That question is really in the right direction that I want to go. The background info is not really necessary since the population of the array has already been made. It was mostly so you can see from where the array is coming and if I might been thinking wrong about this project. Lets say that loading the texfil into an array in the first place would be unnecessary. I will try to build from that and keep you posted if it I get stuck. Commented Apr 20, 2017 at 9:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.