Skip to content
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
49 changes: 48 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//Declare a variable called 'name' that has the value of your name.

/*code here*/
var name = 'Steven Ocampo';

//#2
//create an if statement that checks to see if your name is equal to 'Ben'
Expand All @@ -11,32 +12,49 @@

/*code here*/

if (name === 'Ben'){
console.log('yes');
} else {
console.log('no');
}

//#3
//create an array called 'favoriteFoods'.
//fill it up with the names of several of your favorite foods

/*code here*/

var favoriteFoods = ['Steak', 'Shashimi', 'Sweet Potato', 'Chocolate Ice Cream'];
//#4
//use a for loop to log each food in the 'favoriteFoods' array

/*code here*/

for (let i = 0; i < favoriteFoods.length; i++){
console.log(favoriteFoods[i]);
}
//#5
//create an object called 'favoriteMovie'.
//give 'favoriteMovie' a property called 'runtime' and set it equal to how long the movie is in minutes
//give 'favoriteMovie' a property called 'title' and set it equal to the title
//give 'favoriteMovie' a property called 'director' and set it equal to the director's name

/*code here*/
var favoriteMovie = {};

favoriteMovie['runtime'] = 'minutes'
favoriteMovie['title'] = 'title'
favoriteMovie['director'] = 'director\'s name'
//#6
//create a function called 'sayHi'.
//'sayHi' should accept one argument called 'name'
//when 'sayHi' is invoked it should log the string 'Hello <name>!' where <name> is equal to the 'name' argument

/*code here*/

var sayHi = function(name){
console.log(`Hello ${name}!`);
}

//#7
//create an array called 'friends'
//create three objects that have information about your friends
Expand All @@ -45,18 +63,34 @@

/*code here*/

var friends = [];

var object1 = {name: 'Johny', age: 21, vocation: 'Janitor'};
var object2 = {name: 'Jenny', age: 32, vocation: 'Professor'};
var object3 = {name: 'Kenny', age: 17, vocation: 'Rock Star'};

friends.push(object1, object2, object3);

//#8
//use a for loop to iterate over the 'friends' array from problem #7
//inside the for loop print the string 'My friend <name> is <age> years old and does <vocation> for work.'

/*code here*/

for (let i = 0; i < friends.length; i++){
console.log(`My friend ${friend[i].name} is ${friend[i].age} years old and does ${friend[i].vocation} for work.`);
}

//#9
//create a constructor called 'User' that can function as a class for creating new user objects
//'User' should take 'email', and 'password' as arguments
//each instance of 'User' that is created should have a 'email', and 'password' property that is equal to the arguments passed to the constructor

/*code here*/
function User(email, password){
this.email = email;
this.password = password;
}

//#10
//create a function called 'nFactorial(num)'
Expand All @@ -65,3 +99,16 @@
//try to solve this recursively

/*code here*/


var nFactorial(num){
if (num < 2) {
return 1;
} else {
return num * (nFactorial(num - 1));
}

}