Skip to content

Instantly share code, notes, and snippets.

@djds23
Created May 13, 2020 22:55
Show Gist options
  • Save djds23/e8941304ad8e1f173a3a3404e372cf9f to your computer and use it in GitHub Desktop.
Save djds23/e8941304ad8e1f173a3a3404e372cf9f to your computer and use it in GitHub Desktop.
/*
The answers to each of these questions should be written as a function.
Call the function to execute your code.
Open this file in a text editor like "Sublime Text" or "Notepad++"
Write your answers in this file, saving often.
Copy & paste your code into the sandbox in order to run it & test that it works
Sandbox: https://eloquentjavascript.net/code/
_Reminder_
You declare variables using the `let` keyword and populate them with the `=` operator.
The following are both valid:
let myVariable1;
myVariable1 = 1;
let myVariable2 = 2;
Use variables to store values so they may be referred to later.
*/
/*
Exercise 1)
Define 5 variables and assign them the following info:
* Your first name (string)
* Your favorite number (number)
* If you enjoy eating kale (boolean)
* A movie title (string)
* A song title (string)
Send each variable to console.log to print them and ensure they are correct.
Example:
let firstName = "Dean";
console.log(firstName); // Dean
let movieTitle = "Moonrise Kingdom";
console.log(favoriteNumber); // Moonrise Kingdom
*/
// Replace these
let firstName = "";
console.log(firstName);
/*
Exercise 2)
Write a function that takes a first name and a movie title and returns a greeting in the following format:
"Hi! My name is $NAME and I enjoy the movie $MOVIE"
Use the variables from Exercise 1 for the input here.
Example
console.log(movieGreeting(firstName, movieTitle)); // "Hi! My name is Dean and I enjoy the movie Moonrise Kingdom"
Bonus: Can you get quotes around the movie title?
*/
console.log(movieGreeting(firstName, movieTitle));
/*
Exercise 3)
Write a function _that prompts the user_ to ask their favorite food.
Print out a greeting to that user with their favorite food:
Oh you enjoy $FOOD too? I thought I was the only one.
Tip:
* JavaScript has a function `prompt`, that will throw up a text box for the user. `prompt` returns the input as a string.
* `prompt` takes a string as an argument that it will display to the user
* IE: `prompt("What is your name")` will show the user a box asking what their name
*/
checkFavoriteFood();
/*
Exercise 4)
Write a function that prompts the user for a "fun fact" and stores their input as a variable.
Call our `isSentence` function from last week with the input we stored.
If the user provided a fun fact as a complete sentence, then tell them their fun fact is interesting.
If the fun fact is not a complete sentence, then instruct them to please use a period at the end of their sentences.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment