function InitGame() {
        card3.appendChild(card3Image);

        targetIndex = Math.floor((Math.random() * wordsSet1.length)); //randomly choose target word
        word1Index = Math.floor((Math.random() * wordsSet1.length)); //randomly choose word1 index
        while (word1Index == targetIndex)  //choose again if same as another index
            word1Index = Math.floor((Math.random() * wordsSet1.length)); //randomly choose word1 index
        word2Index = Math.floor((Math.random() * wordsSet1.length)); //randomly choose word2 index
        while (word2Index == targetIndex || word2Index == word1Index)  //choose again if same as another index
            word2Index = Math.floor((Math.random() * wordsSet1.length)); //randomly choose word2 index

        targetImage.src = wordsSet1[targetIndex];   //target card
        card3Image.src = wordsSet2[targetIndex];    //matching card
        card1Image.src = wordsSet1[word1Index];     //incorrect matching card 1
        card2Image.src = wordsSet1[word2Index];     //incorrect matching card 2

        var cardCoord = ['5%', '37.5%', '70%']; //coordinate for word cards at bottom of screen

        var index3 = Math.floor((Math.random() * cardCoord.length));
        card3.style.marginLeft = cardCoord[index3];  //randomly set location of target card
        var index2 = Math.floor((Math.random() * cardCoord.length));
        while (index2 == index3)
            index2 = Math.floor((Math.random() * cardCoord.length));
        card2.style.marginLeft = cardCoord[index2]; //randomly set location of first word card
        var index1 = Math.floor((Math.random() * cardCoord.length));
        while (index1 == index2 || index1 == index3)
            index1 = Math.floor((Math.random() * cardCoord.length));
        card1.style.marginLeft = cardCoord[index1]; //randomly set location of second word card

        correct.setVolume(.1);
        tryAgain.setVolume(.1);
        GameIntro();    //call function to play directions
    }
//randomly choose and play all word cards
randomly choose and play all word cards
randomly choose and play all word cards
function InitGame() {
        card3.appendChild(card3Image);
        targetIndex = Math.floor((Math.random() * wordsSet1.length)); 
        word1Index = Math.floor((Math.random() * wordsSet1.length)); 
        while (word1Index == targetIndex)  
            word1Index = Math.floor((Math.random() * wordsSet1.length)); 
        word2Index = Math.floor((Math.random() * wordsSet1.length)); 
        while (word2Index == targetIndex || word2Index == word1Index)  
            word2Index = Math.floor((Math.random() * wordsSet1.length)); 
        targetImage.src = wordsSet1[targetIndex];   
        card3Image.src = wordsSet2[targetIndex];    
        card1Image.src = wordsSet1[word1Index];     
        card2Image.src = wordsSet1[word2Index];     
        var cardCoord = ['5%', '37.5%', '70%']; 
        var index3 = Math.floor((Math.random() * cardCoord.length));
        card3.style.marginLeft = cardCoord[index3];  
        var index2 = Math.floor((Math.random() * cardCoord.length));
        while (index2 == index3)
            index2 = Math.floor((Math.random() * cardCoord.length));
        card2.style.marginLeft = cardCoord[index2]; 
        var index1 = Math.floor((Math.random() * cardCoord.length));
        while (index1 == index2 || index1 == index3)
            index1 = Math.floor((Math.random() * cardCoord.length));
        card1.style.marginLeft = cardCoord[index1]; 
        correct.setVolume(.1);
        tryAgain.setVolume(.1);
        GameIntro();    
    }
function InitGame ( ) { card3 . appendChild ( card3Image ) ; targetIndex = Math . floor ( ( Math . random ( ) * wordsSet1 . length ) ) ; word1Index = Math . floor ( ( Math . random ( ) * wordsSet1 . length ) ) ; while ( word1Index == targetIndex ) word1Index = Math . floor ( ( Math . random ( ) * wordsSet1 . length ) ) ; word2Index = Math . floor ( ( Math . random ( ) * wordsSet1 . length ) ) ; while ( word2Index == targetIndex || word2Index == word1Index ) word2Index = Math . floor ( ( Math . random ( ) * wordsSet1 . length ) ) ; targetImage . src = wordsSet1 [ targetIndex ] ; card3Image . src = wordsSet2 [ targetIndex ] ; card1Image . src = wordsSet1 [ word1Index ] ; card2Image . src = wordsSet1 [ word2Index ] ; var cardCoord = [ '5%' , '37.5%' , '70%' ] ; var index3 = Math . floor ( ( Math . random ( ) * cardCoord . length ) ) ; card3 . style . marginLeft = cardCoord [ index3 ] ; var index2 = Math . floor ( ( Math . random ( ) * cardCoord . length ) ) ; while ( index2 == index3 ) index2 = Math . floor ( ( Math . random ( ) * cardCoord . length ) ) ; card2 . style . marginLeft = cardCoord [ index2 ] ; var index1 = Math . floor ( ( Math . random ( ) * cardCoord . length ) ) ; while ( index1 == index2 || index1 == index3 ) index1 = Math . floor ( ( Math . random ( ) * cardCoord . length ) ) ; card1 . style . marginLeft = cardCoord [ index1 ] ; correct . setVolume ( .1 ) ; tryAgain . setVolume ( .1 ) ; GameIntro ( ) ; }
randomly choose and play all word cards
randomly choose and play all word cards
//randomly choose target word //randomly choose word1 index //choose again if same as another index //randomly choose word1 index //randomly choose word2 index //choose again if same as another index //randomly choose word2 index //target card //matching card //incorrect matching card 1 //incorrect matching card 2 //coordinate for word cards at bottom of screen //randomly set location of target card //randomly set location of first word card //randomly set location of second word card //call function to play directions