Skip to content

Dev-AbdulHannan/Lab--Kitchen-Sink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

JavaScript Kitchen Sink The objective of this lab assignment is to practice using the fundamentals of JavaScript that were explored in lecture.

Required Create a new project folder and copy this lab into a README.md file. Create an index.html file and an app.js file and link the two together with a script tag. Connect this project folder to a GitHub repository. And back to JavaScript: create a variable that contains your name as a value. Name the variable appropriately. Create a constant that contains the number of states in the U.S. and name it appropriately. Compute the result of adding 5 and 4 and store it in an appropriately named variable. Add comments to your code to document its functionality Write a function called sayHello that displays an alert that says Hello World! Call the sayHello function. Write a function called checkAge that takes two arguments: one for a name and one for an age. If the age is less than 21, display an alert that says, "Sorry " + name + ", you aren't old enough to view this page!" Call the checkAge function 4 times with the following people: Charles who is 21, Abby who is 27, James who is 18, and John who is 17. Hint: scroll down to "JavaScript String Operators" to see how to combine a variable with a string correctly. Create an array of your favorite vegetables and name it accordingly.

  • Use a loop to display each of your favorite vegetables to the developer console. Create an object named pet with two properties, name and breed. Use your own pets name and breed as the values! Or make one up if you don't own a pet. Display a console log displaying your pets name and breed after creating your pet object. Create an array of 5 objects that contain name and age properties. Make up names and ages for each object, making sure some are younger than 21 and some are 21+.
  • Use a loop to call the checkAge function for each object in the array, passing the object's name and age as arguments. Create a function called getLength that takes any word as an argument. The function should return the number of characters in the string.
  • Call the getLength function, passing 'Hello World' as the argument. Store the returned result of that function in a variable.
  • If the number is even, display 'The world is nice and even!' in the developer console. Otherwise if the number is odd, display 'The world is an odd place!' in the developer console. Submit to Github Commit your changes and push to GitHub.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages