JavaScript Help A string contains words separate by blank sp

JavaScript Help: A string contains words separate by blank spaces. How do you extract the first word?

One example would be:

**Question: Propose an alternative way at producing such a solution.

Solution

<script>

var str=\"The Canadians are now worried about NAFTA\";

var words = str.split(\" \");

document.write(words[0]);

</script>

Output:

The

JavaScript Help: A string contains words separate by blank spaces. How do you extract the first word? One example would be: **Question: Propose an alternative w

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site