Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Study Js 1 #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 50 additions & 16 deletions practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,33 @@
//Create a variable called myName that is a string data type

//Code here

var myName = ''
//////////////////PROBLEM 2////////////////////

//Create a variable called myAge that is a number data type

//Code here

var myAge = 28
//////////////////PROBLEM 3////////////////////

//Create a variable called lovesCode that is a boolean data type

//Code here
var lovesCode = true

//////////////////PROBLEM 4////////////////////

//Create a variable called greatestFear that is undefined because we fear nothing

//Code here
var greatestFear = undefined

//////////////////PROBLEM 5////////////////////

//Create a variable called devMountainGoal that is null because we are just starting out

//Code here

var devMountainGoal = null
//////////////////PROBLEM 6////////////////////

//Create a function declaration called greeting that
Expand All @@ -36,21 +38,25 @@
//plus the value of the name parameter.

//Code here

function greeting(name){
return "Hello, " + name
}
//////////////////PROBLEM 7////////////////////

//Write a function expression called newGreeting.
//Give it the same functionality as the function greeting in Problem 6.

//Code Here

var newGreeting = function(name){
return 'Hello, ' + name
}
//////////////////PROBLEM 8////////////////////

//Create an array called groceries with the values
//"apples", "milk", "eggs", "bread"

//Code Here

var groceries = ['apples', 'milk', 'eggs', 'bread']
//////////////////PROBLEM 9////////////////////

//Create an object saved to the variable dog.
Expand All @@ -59,12 +65,17 @@
//and goodBoy (a boolean).

//Code Here

var dog = {
name: 'Nala',
color: 'Grey',
age: 2,
goodBoy: true
}
//...access the dog's name from the object and assign it to a
//variable called devMountainClassPet.

//Code Here

var devMountainClassPet = dog['name']
//////////////////PROBLEM 10////////////////////

//Write a function called nameCheck that takes in a name parameter.
Expand All @@ -75,20 +86,30 @@
// with NAMEPARAM being the name parameter being passed in (not literally NAMEPARAM)

// Code here

function nameCheck(name){
if (name === "Steven"){
return "What is up Steven?"
} else if (name === "Bryan"){
return "Hey Bryan!"
} else {
return 'Cool name, ' + name
}
}
//////////////////PROBLEM 11////////////////////

// Create a function called add that takes in two parameters
// that will be numbers.
// The add function should return the two parameters added together

//Code Here

function add(num1,num2){
return num1 + num2
}
//Now invoke add, passing in the numbers 3 and 4
//storing the result in the variable mathSum.

//Code Here

var mathSum = add(3,4)
//////////////////PROBLEM 12////////////////////

//Write a function called faveColorFinder that takes in one parameter called color
Expand All @@ -99,6 +120,17 @@
// Otherwise, you should return the string 'you need to evaluate your favorite color choice'

// Code here
function faveColorFinder(color){
if (color === 'red'){
return 'red is a great color'
} else if (color === 'green'){
return 'green is a solid favorite color'
} else if (color === 'black'){
return 'so trendy'
} else {
return 'you need to evaluate your favorite color choice'
}
}

//////////////////PROBLEM 13////////////////////

Expand All @@ -122,28 +154,30 @@ function pond() {
//as strings.

//This array should contain the variable names (as strings) accessible in the global scope.
let globalScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
let globalScope = ["duck"];

//This array should contain the variable names (as strings) accessible in the bathroom function.
let bathroomScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
let bathroomScope = ["duck", "rubberDuck"];

//This array should contain the variable names (as strings) accessible in the bathtub function.
let bathtubScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
let bathtubScope = ["duck", "sailorDuck", "rubberDuck"];

//This array should contain the variable names (as strings) accessible in the pond function.
let pondScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
let pondScope = ["duck", "realDuck"];

//////////////////PROBLEM 14////////////////////

//Create a variable called age with your age assigned to you

// Code Here
var age = 29

// FLASH FORWARD TO NEXT YEAR
// reassign the value of age to be one greater than it was, because, we all get older

// Code Here

age ++
// Good news! We can live forever. Set your age to 999

// Code Here
age = 999