/*Hello, I really hope someone can help me out with this function. I'm a newbie to JavaScript. I have included the instructions for the swapFE() function that I have to complete below along with the functions that I have done so far.


I need to create a swap function. The purpose of this function is to exchange the French phrase for the English translation. The function has a single parameter, the event object e.

a. store the source of the event in a variable named phrase. This variable represents the phrase that was clicked in the document. I need to create a cross-browser function or insert code that will determine the source of the event.

b. There are 10 phrases in the document. Determine the phrase number by extracting the integer value from the previous sibling of the phrase node. I have to use the parseInt() function to apply it to the inner content of the previous sibling node. Store the phrase number in the variable phrasenum.

c. The index values from the English and French arrays range from 0 to 9. Change the inner content of the phrase node to the value of the array item english[phrasenum -1] where phrasenum is the value of the phrasenum variable.

d. Change the font style of the phrase node to normal. Change the color of the phrase node to the color value(155, 102,102).
*/


function eventSource(e) {
var IE = document.attachEvent ? true:false;
Var DOM = document.addEventListener ? true:false;
if (IE) return event.srcElement;
else
if (DOM) return e.currentTarget;
}

function SetUpTranslation () {
var phrases = document.getElementsByTagName('p');
for (var i=0; i<p.attributes.length;i++){
phrases.secondNode.innerHTML=french[i];
element.onclick=swapFE(phrase.childNode[1]);
element.onmousedown=swapFE(phrases.childNode[1]);
}
}

/*This is the function I need help with*/

function swapFe(e) {
var phrase = eventSource(e);
var phrasenum = parseInt(phrase.previousSibling.innerHTML = english[phrasenum -1].value);

}

/* Thanks for your assistance.*/

To complete the swapFe() function, you need to follow the instructions provided:

a. In the swapFe() function, store the source of the event in a variable named "phrase". You can achieve this by calling the eventSource() function and passing the event object "e" as a parameter. This will return the source of the event.

b. To determine the phrase number, extract the integer value from the previousSibling of the phrase node. Use the parseInt() function to convert the inner content of the previousSibling node to an integer. Store the phrase number in a variable named "phrasenum".

c. Change the inner content of the phrase node to the value of the array item "english[phrasenum - 1]". Use the "phrasenum" variable to access the correct index value in the "english" array.

d. Change the font style of the phrase node to "normal" and the color to the RGB value (155, 102, 102).

Here's the updated code for the swapFe() function:

```javascript
function swapFe(e) {
var phrase = eventSource(e);
var phrasenum = parseInt(phrase.previousSibling.innerHTML);
phrase.innerHTML = english[phrasenum - 1];
phrase.style.fontStyle = "normal";
phrase.style.color = "rgb(155, 102, 102)";
}
```

Make sure to also define the "english" array somewhere in your code, as it is referenced in the swapFe() function.

I hope this helps! Let me know if you have any further questions.

To complete the swapFe() function, you will need to follow these steps:

a. Store the source of the event in a variable named "phrase". This can be done using the eventSource() function you provided. The line `var phrase = eventSource(e);` will do the job.

b. Extract the phrase number from the previous sibling of the phrase node. To do this, you need to access the inner content of the previous sibling and convert it to an integer using the parseInt() function. The line `var phrasenum = parseInt(phrase.previousSibling.innerHTML);` will accomplish this.

c. Change the inner content of the phrase node to the value of the corresponding item in the "english" array. You can access the value using `english[phrasenum - 1]`. The line `phrase.innerHTML = english[phrasenum - 1];` will achieve this.

d. Change the font style and color of the phrase node. To change the font style to normal, you can use `phrase.style.fontStyle = "normal";`. To change the color of the phrase node, you can use `phrase.style.color = "rgb(155, 102, 102)";`.

Here is the complete implementation of the swapFe() function:

```javascript
function swapFe(e) {
var phrase = eventSource(e);
var phrasenum = parseInt(phrase.previousSibling.innerHTML);
phrase.innerHTML = english[phrasenum - 1];
phrase.style.fontStyle = "normal";
phrase.style.color = "rgb(155, 102, 102)";
}
```

Make sure you have defined the "english" array before using it in the swapFe() function, as it is not provided in your code snippet.