Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with code for For Loop
    primarykey
    data
    text
    <p>I am doing a project for school and I'm really struggling to understand how to create the code/commands for my for loop in Javascript. Any help would be greatly appreciated.</p> <p>The project is basically this: -There are two arrays: one set of 10 French words another with a set of 10 Engish words. They look like this:</p> <pre><code>var english=new Array(); english[0]="This hotel isn't far from the Eiffel Tower."; english[1]="What time does the train arrive?"; english[2]="We have been waiting for the bus for one half-hour."; english[3]="This meal is delicious"; english[4]="What day is she going to arrive?"; english[5]="We have eleven minutes before the train leaves!"; english[6]="Living in a foreign country is a good experience."; english[7]="Excuse me! I'm late!"; english[8]="Is this taxi free?"; english[9]="Be careful when you go down the steps."; var french=new Array(); french[0]="Cet h&amp;#244;tel n'est pas loin de la Tour Eiffel."; french[1]="A quelle heure arrive le train?"; french[2]="Nous attendons l'autobus depuis une demi-heure."; french[3]="Ce repas est d&amp;#233;licieux"; french[4]="Quel jour va-t-elle arriver?"; french[5]="Nous avons onze minutes avant le d&amp;#233;part du train!"; french[6]="Habiter dans un pays &amp;#233;tranger est une bonne exp&amp;#233;rience."; french[7]="Excusez-moi! Je suis en retard!"; french[8]="Est-ce que ce taxi est libre?"; french[9]="Faites attention quand vous descendez l'escalier."; </code></pre> <p>-I have to create a function named setUpTranslation(). The purpose of the function is to place the French phrases into the document and set up the event handlers for the mouse-down and mouse-up events. </p> <p>To create the For Loop it says "create a for loop that loops through each of the objects in the phrases collection. For each object in the collection do the following: 1.Change the inner content of the second child node of the object to french[i] where i is the value of the counter variable for the for loop. 2.Run the swapFE() function in reponse to the mouse-down event occurring within the object's second child node 3.Run the swapEF() function in response to a mouse-up event occurring within the object's second child node.</p> <p>Then after setting up the for loop I'm to work on the swapFE() and swapEF() functions. But right now I'm just trying to fix the for loop.</p> <p>Here's what I have so far for the setUpTranslation function:</p> <pre><code>function setUpTranslation() { var phrases = document.getElementsByTagName("p"); for (i = 0; i&lt; phrases.length; i++) { } } </code></pre> <p>I have tried numerous code in the for loop but none of it seems to display the French phrase. Thanks for any and all help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload