03. Console Variables πŸ‘©β€πŸŽ“πŸ‘¨β€πŸŽ“

πŸ—οΈ Link External JavaScript File andLog Introduction Messages to Console Using Values Stored in Variables

  • As a developer, I want to link an external JavaScript file to an existing index.html file to add JavaScript functionality to my static webpage. I also want to input data about my name, the number of pets I own, and a fun fact about myself and log that introduction to the console.

Acceptance Criteria

  • It’s done when I open the index.html file, navigate to the console, and see the message contained in the script.js file logged to the console.

  • It’s done when I store a name in a variable called personName and this line is logged to the console: “My name is VALUE_STORED_IN_VARIABLE_NAME.”

  • It’s done when I store a number in a variable called pets and this line is logged to the console: “I have VALUE_STORED_IN_VARIABLE_PETS pet(s).”

  • It’s done when I store a fun fact in a variable called funFact and this line is logged to the console: “Fun fact: VALUE_STORED_IN_VARIABLE_FUNFACT.”

πŸ’‘ Hints

How can we combine values using the concatenation operator (+) to log a single message to the console?

πŸ† Bonus

If you have completed this activity, work through the following challenge to further your knowledge:

  • What happens when you concatenate two variables in a single console log using +? Is the result what you expected? Why or why not?

Use Google or another search engine to research this.


βœ… Solutions

Solutions Click Here