Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
JohnAdemoye.html
Oluwaseyi.html
README.md
chinkeki.html

README.md

Project JavaScript D2 Functions

Topics: Blocks and Scope , Global Scope , Block Scope , Scope Pollution , Practice Good Scoping

Project Title: Color Picker

  1. Create a html file with your name like john.html
  2. Add current code to that file:
<!DOCTYPE html>
<html>
  <body>
    <script>
      // your code here
    </script>
  </body>
</html>
  1. Define a global variable named color with const and set it to blue

  2. Declare a function named logColor1 without parameter and log color variable into console.

  3. Declare a function named logColor2 with a parameter named color and log color variable into console.

  4. Call function logColor2 with 'red' as argument and check the result.

  5. Declare a function named logColor3 with a parameter named color and log color variable into console.

  6. In this function, add an if statement before console.log that check color is green. If it is green use let to define a variable named color and set it light green, then console.log(color)

  7. Call function logColor3 with 'green' as argument and check the result.

  8. Analyze and discuss the behaviour of scoping in all steps.

Want to get reviewed?

Send Pull Request. Check how to deliver your code: https://codingwithbasir.com/how-to-deliver-projects/

Need help?

Download Learn JavaScript eBook from https://codingwithbasir.com/learn-javascript

You can’t perform that action at this time.