From 0709306837e48249a905273d7282ffaaef66c6a4 Mon Sep 17 00:00:00 2001 From: Saddam Date: Fri, 15 May 2020 08:22:32 +0530 Subject: [PATCH 1/3] Saddam Add remaining codes --- practice.js | 71 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/practice.js b/practice.js index 526c620..cea4e6e 100644 --- a/practice.js +++ b/practice.js @@ -2,31 +2,30 @@ //Create a variable called myName that is a string data type -//Code here +var myName="Saddam"; //////////////////PROBLEM 2//////////////////// //Create a variable called myAge that is a number data type -//Code here +var myAge=20; //////////////////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 - +Let greatestFear; //////////////////PROBLEM 5//////////////////// //Create a variable called devMountainGoal that is null because we are just starting out -//Code here +var devMountainGoal=null; //////////////////PROBLEM 6//////////////////// @@ -35,21 +34,26 @@ //greeting should return the string "Hello, " //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 +function newGreeting(name){ + return "Hello"+name; +} //////////////////PROBLEM 8//////////////////// //Create an array called groceries with the values //"apples", "milk", "eggs", "bread" -//Code Here +var groceries=["apples","milk","egg","bread"]; + //////////////////PROBLEM 9//////////////////// @@ -58,12 +62,16 @@ //name (a string), color (a string), age (a number), //and goodBoy (a boolean). -//Code Here +var dog={ + name:'sammy', + age:4, + goodBoy:true, +}; //...access the dog's name from the object and assign it to a //variable called devMountainClassPet. -//Code Here +devMountainClassPet=dog.name; //////////////////PROBLEM 10//////////////////// @@ -74,7 +82,17 @@ // If the name parameter is anything else, return 'Cool name, NAMEPARAM' // 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//////////////////// @@ -82,12 +100,15 @@ // that will be numbers. // The add function should return the two parameters added together -//Code Here +function add(n1,n2){ + return n1+n2; +} //Now invoke add, passing in the numbers 3 and 4 //storing the result in the variable mathSum. -//Code Here +mathSum=add(3,4); + //////////////////PROBLEM 12//////////////////// @@ -98,7 +119,19 @@ // If the passed in color equals 'black', return 'so trendy' // 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 greate color"; + } + else if (color=="green") { + return "green is a solid favourite color"; + }else if(color="black"){ + return "so trendy" + } + else { + return "you need to evaluate your favourite color choice"; + } +} //////////////////PROBLEM 13//////////////////// @@ -137,13 +170,11 @@ let pondScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"]; //Create a variable called age with your age assigned to you -// Code Here +var age=20; // 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; From 8181c86d66ab01fb7a9456655f23d915f44a4b29 Mon Sep 17 00:00:00 2001 From: Saddam Date: Mon, 18 May 2020 12:38:20 +0530 Subject: [PATCH 2/3] name vaiable added --- practice.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/practice.js b/practice.js index cea4e6e..a97a175 100644 --- a/practice.js +++ b/practice.js @@ -2,7 +2,7 @@ //Create a variable called myName that is a string data type -var myName="Saddam"; +var myName = "Saddam"; //////////////////PROBLEM 2//////////////////// From 33b50d87a8598dca7dbeeb29ba1751b2f116f7b2 Mon Sep 17 00:00:00 2001 From: Saddam Date: Mon, 18 May 2020 13:34:45 +0530 Subject: [PATCH 3/3] Every problem solved successfully --- practice.js | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/practice.js b/practice.js index a97a175..dfe4b4e 100644 --- a/practice.js +++ b/practice.js @@ -20,7 +20,7 @@ var lovesCode=true; //Create a variable called greatestFear that is undefined because we fear nothing -Let greatestFear; +var greatestFear; //////////////////PROBLEM 5//////////////////// //Create a variable called devMountainGoal that is null because we are just starting out @@ -35,7 +35,7 @@ var devMountainGoal=null; //plus the value of the name parameter. function greeting(name){ - return "Hello"+name; + return "Hello, "+name; } //////////////////PROBLEM 7//////////////////// @@ -43,16 +43,17 @@ function greeting(name){ //Write a function expression called newGreeting. //Give it the same functionality as the function greeting in Problem 6. -function newGreeting(name){ - return "Hello"+name; +var newGreeting=function (name){ + return "Hello, "+name; } +newGreeting(); //////////////////PROBLEM 8//////////////////// //Create an array called groceries with the values //"apples", "milk", "eggs", "bread" -var groceries=["apples","milk","egg","bread"]; +var groceries=["apples", "milk", "eggs", "bread"]; //////////////////PROBLEM 9//////////////////// @@ -64,6 +65,7 @@ var groceries=["apples","milk","egg","bread"]; var dog={ name:'sammy', + color:'black', age:4, goodBoy:true, }; @@ -71,7 +73,7 @@ var dog={ //...access the dog's name from the object and assign it to a //variable called devMountainClassPet. -devMountainClassPet=dog.name; +var devMountainClassPet=dog.name; //////////////////PROBLEM 10//////////////////// @@ -84,13 +86,13 @@ devMountainClassPet=dog.name; function nameCheck(name){ if(name=="Steven"){ - return "What is up Steven"; + return "What is up Steven?"; } else if (name=="Bryan") { return "Hey Bryan!"; } else { - return "cool Name"+name; + return "Cool name, "+name; } } @@ -121,15 +123,16 @@ mathSum=add(3,4); function faveColorFinder(color){ if(color=="red"){ - return "red is greate color"; + return 'red is a great color'; } - else if (color=="green") { - return "green is a solid favourite color"; - }else if(color="black"){ - return "so trendy" + else if(color=="green"){ + return 'green is a solid favorite color'; } - else { - return "you need to evaluate your favourite color choice"; + else if(color=="black"){ + return'so trendy'; + } + else{ + return 'you need to evaluate your favorite color choice'; } } @@ -155,16 +158,16 @@ 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"]; +var bathroomScope = ["duck","rubberDuck"]; //This array should contain the variable names (as strings) accessible in the bathtub function. -let bathtubScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"]; +var bathtubScope = ["duck","rubberDuck","sailorDuck"]; //This array should contain the variable names (as strings) accessible in the pond function. -let pondScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"]; +var pondScope = ["duck","realDuck"]; //////////////////PROBLEM 14//////////////////// @@ -177,4 +180,4 @@ var age=20; age++ // Good news! We can live forever. Set your age to 999 -age=999; +age=999; \ No newline at end of file