JavaScript - Intelligent Interaction

In this lesson you will begin to explore “intelligent” interactivity by creating a script that prompts the user with a question, evaluates the response, then provides feedback based on that response.

“What’s the difference between local and global variables in JavaScript?”
sample interview question

So now you’ve gotten your toes wet and inserted little bits of javascript that run when the page loads or when you click on a link, right? It's cute and all... but what if you had multiple links, or hundreds of links that you wanted to attach javascript to? Using the methods we’ve used so far — you would have to write a different script for each link, that would be a lot of javascript! Nobody has time for that. So if we know that all the hundreds of links we have on a page are supposed to behave in a similar way, only with a slightly different outcome, then we could write the code just once — in a function!

A function is basically a piece of code that sits dormant in the script somewhere and gets activated only when something tells it to do its job. And you can alter the outcome of function through the use of what are known as arguments. You can read Mozilla Developer Network's Documentation for Function or you can just breeze through the JavaScript Functions over at w3Schools — Functions but you must take all five Codecademy — Functions in JavaScript sections and come back when you’re ready to begin.

Codecademy: Functions in JavaScript
What's next? Do the challenge!

1 Comments — Join the discussion

  • 768af3def250eed3bbd49cd1e562b6f5?&s=30&d=mmLenny

    The more of these I complete, the more I realize I know and also dont know.