From 9f886911206fdcfc7842e5473bc758b90524bb29 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Thu, 12 Aug 2021 14:51:00 -0500 Subject: [PATCH 01/42] Inline js --- inline_js.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 inline_js.js diff --git a/inline_js.js b/inline_js.js new file mode 100644 index 0000000..e69de29 From 368d7e54d254dee8d0e4a53ff72bafc4a374c37c Mon Sep 17 00:00:00 2001 From: john alejandro Date: Thu, 12 Aug 2021 15:15:13 -0500 Subject: [PATCH 02/42] new folders --- external_js.html | 10 ++++++++++ inline_js.html | 10 ++++++++++ inline_js.js | 0 js.html | 11 +++++++++++ 4 files changed, 31 insertions(+) create mode 100644 external_js.html create mode 100644 inline_js.html delete mode 100644 inline_js.js create mode 100644 js.html diff --git a/external_js.html b/external_js.html new file mode 100644 index 0000000..588ba3f --- /dev/null +++ b/external_js.html @@ -0,0 +1,10 @@ + + + + + External JS + + + + + \ No newline at end of file diff --git a/inline_js.html b/inline_js.html new file mode 100644 index 0000000..c567d48 --- /dev/null +++ b/inline_js.html @@ -0,0 +1,10 @@ + + + + + Inline JS + + + console.log("Hello from inline JavaScript") + + \ No newline at end of file diff --git a/inline_js.js b/inline_js.js deleted file mode 100644 index e69de29..0000000 diff --git a/js.html b/js.html new file mode 100644 index 0000000..364a5de --- /dev/null +++ b/js.html @@ -0,0 +1,11 @@ + + + + + external.js + + + console.log("Hello from external JavaScript") + + + \ No newline at end of file From 5bc72da796bf5f5c67882654cf9b1676625e64bc Mon Sep 17 00:00:00 2001 From: john alejandro Date: Thu, 12 Aug 2021 20:08:24 -0500 Subject: [PATCH 03/42] movie rental total --- inline_js.html | 7 ++++++- js.html | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/inline_js.html b/inline_js.html index c567d48..d93e144 100644 --- a/inline_js.html +++ b/inline_js.html @@ -5,6 +5,11 @@ Inline JS - console.log("Hello from inline JavaScript") + console.log("Hello from Inline JavaScript."); + \ No newline at end of file diff --git a/js.html b/js.html index 364a5de..931ebaf 100644 --- a/js.html +++ b/js.html @@ -5,7 +5,18 @@ external.js - console.log("Hello from external JavaScript") - + \ No newline at end of file From 83af326296f238e1c7a6310c07178283a61bdb82 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Thu, 12 Aug 2021 21:53:08 -0500 Subject: [PATCH 04/42] Pay for hours worked --- js.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js.html b/js.html index 931ebaf..97091be 100644 --- a/js.html +++ b/js.html @@ -17,6 +17,23 @@ var num3 = Number(c); var result = Number(a)+Number(b)+Number(c); alert("Your total is $" + result * 3 ); + + + \ No newline at end of file From 18f9399259d5666e1e662268db3f5edf23362796 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Fri, 13 Aug 2021 08:28:05 -0500 Subject: [PATCH 05/42] Enrollment/Offer Code --- js.html | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/js.html b/js.html index 97091be..ddd919f 100644 --- a/js.html +++ b/js.html @@ -32,8 +32,35 @@ alert("Your pay check will be $" + result + " for the hours worked this week"); + \ No newline at end of file From c65fd16a8366b4584c84d9b31f34f7ca33a4cc34 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Fri, 13 Aug 2021 11:14:52 -0500 Subject: [PATCH 06/42] Hello --- Function-Lec..js | 83 +++++++++++++++++++++++++++++++++++++++++++++ Functions-Lec..html | 11 ++++++ js.html | 19 ++++++----- 3 files changed, 104 insertions(+), 9 deletions(-) create mode 100644 Function-Lec..js create mode 100644 Functions-Lec..html diff --git a/Function-Lec..js b/Function-Lec..js new file mode 100644 index 0000000..efaea72 --- /dev/null +++ b/Function-Lec..js @@ -0,0 +1,83 @@ +"use strict"; + +/** + * TODO: + * Create a function called 'sayHello' that takes a parameter 'name'. + * When called, the function should return a message that says hello to the passed in name. + * function sayHello ("John") { + * consolelog.("Hello") + * } + * Example + * > sayHello("codeup") // returns "Hello, codeup!" + */ + +/** + * TODO: + * Call the function 'sayHello' and pass your name as a string literal argument. + * Store the result of the function call in a variable named 'helloMessage'. + * + * console.log 'helloMessage' to check your work + */ + +/** + * TODO: + * Store your name as a string in a variable named 'myName', and pass that + * variable to the 'sayHello' function. You should see the same output in the + * console. + */ + +// Don't modify the following line, it generates a random number between 1 and 3 +// and stores it in a variable named random +var random = Math.floor((Math.random() * 3) + 1); + +/** + * TODO: + * Create a function called 'isTwo' that takes a number as a parameter. + * The function should return a boolean value based on whether or not the passed + * number is the number 2. + * + * Example + * > isTwo(1) // returns false + * > isTwo(2) // returns true + * > isTwo(3) // returns false + * + * Call the function 'isTwo' passing the variable 'random' as a argument. + * + * console.log *outside of the function* to check your work (you should see a + * different result everytime you refresh the page if you are using the random + * number) + */ + +/** + * TODO: + * Create a function named 'calculateTip' to calculate a tip on a bill at a + * restaurant. The function should accept a tip percentage and the total of the + * bill, and return the amount to tip + * + * Examples: + * > calculateTip(0.20, 20) // returns 4 + * > calculateTip(0.25, 25.50) // returns 6.375 + * > calculateTip(0.15, 33.42) // returns 5.013 + */ + +/** + * TODO: + * Use prompt and alert in combination with your calculateTip function to + * prompt the user for the bill total and a percentage they would like to tip, + * then display the dollar amount they should tip + */ + +/** + * TODO: + * Create a function named `applyDiscount`. This function should accept a price + * (before a discount is applied), and a discount percentage (a number between 0 + * and 1). It should return the result of applying the discount to the original + * price. + * + * Example: + * > var originalPrice = 100; + * > var dicountPercent = .2; // 20% + * > applyDiscount(originalPrice, dicountPercent) // 80 + * + * > applyDiscount(45.99, 0.12) // 40.4712 + */ \ No newline at end of file diff --git a/Functions-Lec..html b/Functions-Lec..html new file mode 100644 index 0000000..5c67218 --- /dev/null +++ b/Functions-Lec..html @@ -0,0 +1,11 @@ + + + + + "Welcome to Functions!" + + +

Functions Lecture

+ + + \ No newline at end of file diff --git a/js.html b/js.html index ddd919f..d22f471 100644 --- a/js.html +++ b/js.html @@ -1,10 +1,11 @@ +"use strict" external.js - +< @@ -52,13 +53,13 @@ // console.log("The user entered: " + ussrInput); var Offer = (i > 2) if (Offer is true) { - var result = "Apply"; + var return Apply; } else { - var result = "Do not Apply"; + var return Do not Apply; }if ( f is No) { - var result = "Apply"; + var return Apply; } else { - var result = "Do not Apply"; + var return Do not Apply; } alert("Thank you for your purchase? Ask Cashier about Premium Member Benefits." ) From e9bb2a3f1a7d1ed73c4a402747e6a6678b151c25 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Fri, 13 Aug 2021 11:24:25 -0500 Subject: [PATCH 07/42] Redo --- Function-Lec..js => functions.js | 9 +++++---- Functions-Lec..html => functions_js..html | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) rename Function-Lec..js => functions.js (97%) rename Functions-Lec..html => functions_js..html (78%) diff --git a/Function-Lec..js b/functions.js similarity index 97% rename from Function-Lec..js rename to functions.js index efaea72..7a268b8 100644 --- a/Function-Lec..js +++ b/functions.js @@ -4,9 +4,7 @@ * TODO: * Create a function called 'sayHello' that takes a parameter 'name'. * When called, the function should return a message that says hello to the passed in name. - * function sayHello ("John") { - * consolelog.("Hello") - * } + * Example * > sayHello("codeup") // returns "Hello, codeup!" */ @@ -80,4 +78,7 @@ var random = Math.floor((Math.random() * 3) + 1); * > applyDiscount(originalPrice, dicountPercent) // 80 * * > applyDiscount(45.99, 0.12) // 40.4712 - */ \ No newline at end of file + */ +function sayHello ("John") { + consolelog.("Hello"); +} \ No newline at end of file diff --git a/Functions-Lec..html b/functions_js..html similarity index 78% rename from Functions-Lec..html rename to functions_js..html index 5c67218..9b00ecd 100644 --- a/Functions-Lec..html +++ b/functions_js..html @@ -6,6 +6,6 @@

Functions Lecture

- + \ No newline at end of file From 6aa32a7f4e4e8b2c18c5c42566b7e5caf50bcc6f Mon Sep 17 00:00:00 2001 From: john alejandro Date: Fri, 13 Aug 2021 11:54:03 -0500 Subject: [PATCH 08/42] redo 2 --- functions.js | 15 ++++++++++----- functions_js..html | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/functions.js b/functions.js index 7a268b8..fea4ddb 100644 --- a/functions.js +++ b/functions.js @@ -8,7 +8,10 @@ * Example * > sayHello("codeup") // returns "Hello, codeup!" */ - +function sayHello ("John") { + var ("Hello"); + return +} /** * TODO: * Call the function 'sayHello' and pass your name as a string literal argument. @@ -16,7 +19,10 @@ * * console.log 'helloMessage' to check your work */ - +function sayHello ("John") { + var result = John; + return result; +} /** * TODO: * Store your name as a string in a variable named 'myName', and pass that @@ -24,6 +30,8 @@ * console. */ + + // Don't modify the following line, it generates a random number between 1 and 3 // and stores it in a variable named random var random = Math.floor((Math.random() * 3) + 1); @@ -79,6 +87,3 @@ var random = Math.floor((Math.random() * 3) + 1); * * > applyDiscount(45.99, 0.12) // 40.4712 */ -function sayHello ("John") { - consolelog.("Hello"); -} \ No newline at end of file diff --git a/functions_js..html b/functions_js..html index 9b00ecd..fefe6b0 100644 --- a/functions_js..html +++ b/functions_js..html @@ -6,6 +6,6 @@

Functions Lecture

- + > + \ No newline at end of file diff --git a/functions.js b/js/functions.js similarity index 94% rename from functions.js rename to js/functions.js index fea4ddb..b0a6237 100644 --- a/functions.js +++ b/js/functions.js @@ -8,9 +8,9 @@ * Example * > sayHello("codeup") // returns "Hello, codeup!" */ -function sayHello ("John") { - var ("Hello"); - return +function sayHello (name) { + var message = "Hello, " + name; + return message; } /** * TODO: @@ -19,10 +19,8 @@ function sayHello ("John") { * * console.log 'helloMessage' to check your work */ -function sayHello ("John") { - var result = John; - return result; -} + + /** * TODO: * Store your name as a string in a variable named 'myName', and pass that From 62766ee8d0b2f74f6280bc598e64dad0800ee627 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Fri, 13 Aug 2021 12:36:29 -0500 Subject: [PATCH 10/42] update --- js/functions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index b0a6237..2700553 100644 --- a/js/functions.js +++ b/js/functions.js @@ -19,7 +19,10 @@ function sayHello (name) { * * console.log 'helloMessage' to check your work */ - +function sayHello (name) { + var helloMessage = name; + console.log("helloMessage") +} /** * TODO: @@ -27,7 +30,7 @@ function sayHello (name) { * variable to the 'sayHello' function. You should see the same output in the * console. */ - + var myName = "John"; // Don't modify the following line, it generates a random number between 1 and 3 From 2f0bdf9dcf35d1d981a80b8235bf2aae93095432 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Fri, 13 Aug 2021 13:55:54 -0500 Subject: [PATCH 11/42] udate 3 --- js/functions.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/functions.js b/js/functions.js index 2700553..11a53e1 100644 --- a/js/functions.js +++ b/js/functions.js @@ -20,18 +20,21 @@ function sayHello (name) { * console.log 'helloMessage' to check your work */ function sayHello (name) { - var helloMessage = name; - console.log("helloMessage") + var helloMessage = "John" + name; + return helloMessage; } - + console.log(helloMessage) /** * TODO: * Store your name as a string in a variable named 'myName', and pass that * variable to the 'sayHello' function. You should see the same output in the * console. */ +function sayHello(myName) { + var helloMessage = "Hello" + myName; var myName = "John"; - + return helloMessage +} // Don't modify the following line, it generates a random number between 1 and 3 // and stores it in a variable named random From b3dc86bdc692ff2086bb823b04add98de71ff209 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Fri, 13 Aug 2021 14:56:03 -0500 Subject: [PATCH 12/42] udate 4 --- js/functions.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/js/functions.js b/js/functions.js index 11a53e1..7bb4146 100644 --- a/js/functions.js +++ b/js/functions.js @@ -20,21 +20,17 @@ function sayHello (name) { * console.log 'helloMessage' to check your work */ function sayHello (name) { - var helloMessage = "John" + name; + var helloMessage = "Hello, " + name; return helloMessage; } - console.log(helloMessage) + console.log("helloMessage") /** * TODO: * Store your name as a string in a variable named 'myName', and pass that * variable to the 'sayHello' function. You should see the same output in the * console. */ -function sayHello(myName) { - var helloMessage = "Hello" + myName; var myName = "John"; - return helloMessage -} // Don't modify the following line, it generates a random number between 1 and 3 // and stores it in a variable named random @@ -57,7 +53,14 @@ var random = Math.floor((Math.random() * 3) + 1); * different result everytime you refresh the page if you are using the random * number) */ - +function isTwo(number) { + if (number === 2) { + return true; + }else { + return false; + } +} + console.log(isTwo(random)) /** * TODO: * Create a function named 'calculateTip' to calculate a tip on a bill at a From 3794d1b951f272e253ed166af280fa40f9e76a95 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Sat, 14 Aug 2021 22:45:47 -0500 Subject: [PATCH 13/42] updated work --- js/functions.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/js/functions.js b/js/functions.js index 7bb4146..3fa358f 100644 --- a/js/functions.js +++ b/js/functions.js @@ -8,9 +8,8 @@ * Example * > sayHello("codeup") // returns "Hello, codeup!" */ -function sayHello (name) { - var message = "Hello, " + name; - return message; +function sayHello(name) { + return "Hello, " + name; } /** * TODO: @@ -19,10 +18,8 @@ function sayHello (name) { * * console.log 'helloMessage' to check your work */ -function sayHello (name) { +sayHello(name) var helloMessage = "Hello, " + name; - return helloMessage; -} console.log("helloMessage") /** * TODO: @@ -31,6 +28,7 @@ function sayHello (name) { * console. */ var myName = "John"; + console.log(sayHello(myName)) // Don't modify the following line, it generates a random number between 1 and 3 // and stores it in a variable named random @@ -56,9 +54,8 @@ var random = Math.floor((Math.random() * 3) + 1); function isTwo(number) { if (number === 2) { return true; - }else { - return false; } + return false; } console.log(isTwo(random)) /** @@ -72,7 +69,11 @@ function isTwo(number) { * > calculateTip(0.25, 25.50) // returns 6.375 * > calculateTip(0.15, 33.42) // returns 5.013 */ - +function calculateTip(t,p){ + var t = random; + var tip = t * p; + return tip; +} /** * TODO: * Use prompt and alert in combination with your calculateTip function to From 90be9fcef124aff870d2bde16c81af90c35fe597 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Sat, 14 Aug 2021 23:22:27 -0500 Subject: [PATCH 14/42] update --- js/functions.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/functions.js b/js/functions.js index 3fa358f..120122c 100644 --- a/js/functions.js +++ b/js/functions.js @@ -69,18 +69,21 @@ function isTwo(number) { * > calculateTip(0.25, 25.50) // returns 6.375 * > calculateTip(0.15, 33.42) // returns 5.013 */ -function calculateTip(t,p){ - var t = random; - var tip = t * p; - return tip; +function calculateTip(tipPercentage,total) { + return tippercentage + total; + console.log(calculateTip(tipPercentage,total)) } + /** * TODO: * Use prompt and alert in combination with your calculateTip function to * prompt the user for the bill total and a percentage they would like to tip, * then display the dollar amount they should tip */ - +var userbill = prompt("How much is the bill?"); +var usertip = prompt("How was service and how much would you like to tip?"); +usertip = usertip/100 +alert("Thank you so much: "+ calculateTip(tipPercenatge,total)) /** * TODO: * Create a function named `applyDiscount`. This function should accept a price From cd9d65ff332589c2616b5c313292bd1252ac1145 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Sun, 15 Aug 2021 00:44:56 -0500 Subject: [PATCH 15/42] update --- js/functions.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/js/functions.js b/js/functions.js index 120122c..1dc5dc9 100644 --- a/js/functions.js +++ b/js/functions.js @@ -69,9 +69,8 @@ function isTwo(number) { * > calculateTip(0.25, 25.50) // returns 6.375 * > calculateTip(0.15, 33.42) // returns 5.013 */ -function calculateTip(tipPercentage,total) { - return tippercentage + total; - console.log(calculateTip(tipPercentage,total)) +function calculateTip(total,tippercentage) { + return (total * tippercentage)/100; } /** @@ -80,10 +79,9 @@ function calculateTip(tipPercentage,total) { * prompt the user for the bill total and a percentage they would like to tip, * then display the dollar amount they should tip */ -var userbill = prompt("How much is the bill?"); -var usertip = prompt("How was service and how much would you like to tip?"); -usertip = usertip/100 -alert("Thank you so much: "+ calculateTip(tipPercenatge,total)) +var userbill = prompt("How much is the bill?") +var usertip = prompt("How was service and how much would you like to tip?") +alert("Thank you so much, + "$ ") /** * TODO: * Create a function named `applyDiscount`. This function should accept a price From 3d96f445fa6e1b6fc980c3f9c60e8994c3797313 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Sun, 15 Aug 2021 01:04:23 -0500 Subject: [PATCH 16/42] still trying --- js/functions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index 1dc5dc9..a49907d 100644 --- a/js/functions.js +++ b/js/functions.js @@ -80,8 +80,8 @@ function calculateTip(total,tippercentage) { * then display the dollar amount they should tip */ var userbill = prompt("How much is the bill?") -var usertip = prompt("How was service and how much would you like to tip?") -alert("Thank you so much, + "$ ") +var usertip = prompt("How much would you like to tip?") +alert("Thank you so much, " + "$ ") /** * TODO: * Create a function named `applyDiscount`. This function should accept a price @@ -96,3 +96,6 @@ alert("Thank you so much, + "$ ") * * > applyDiscount(45.99, 0.12) // 40.4712 */ +function applyDiscount(originalprice,discountPercent) { + return originalprice-((originalprice * discountPercent)/100); +} \ No newline at end of file From 2819fd84c90078eef39995b7433966bb27889f13 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Sun, 15 Aug 2021 22:31:27 -0500 Subject: [PATCH 17/42] finally --- js/functions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/functions.js b/js/functions.js index a49907d..8899982 100644 --- a/js/functions.js +++ b/js/functions.js @@ -18,7 +18,7 @@ function sayHello(name) { * * console.log 'helloMessage' to check your work */ -sayHello(name) +sayHello(name); var helloMessage = "Hello, " + name; console.log("helloMessage") /** @@ -72,7 +72,7 @@ function isTwo(number) { function calculateTip(total,tippercentage) { return (total * tippercentage)/100; } - + console.log("calculateTip"); /** * TODO: * Use prompt and alert in combination with your calculateTip function to @@ -81,7 +81,7 @@ function calculateTip(total,tippercentage) { */ var userbill = prompt("How much is the bill?") var usertip = prompt("How much would you like to tip?") -alert("Thank you so much, " + "$ ") +alert("Thank you so much, here's your tip " + "$" + usertip + "."); /** * TODO: * Create a function named `applyDiscount`. This function should accept a price From 3e5c7909db132e76faafbf3024f239afeb17c7f7 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Sun, 15 Aug 2021 22:47:53 -0500 Subject: [PATCH 18/42] got it --- js/functions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index 8899982..1c2e5f0 100644 --- a/js/functions.js +++ b/js/functions.js @@ -97,5 +97,6 @@ alert("Thank you so much, here's your tip " + "$" + usertip + "."); * > applyDiscount(45.99, 0.12) // 40.4712 */ function applyDiscount(originalprice,discountPercent) { - return originalprice-((originalprice * discountPercent)/100); -} \ No newline at end of file + var discount = originalprice-(originalprice * discountPercent); + return discount; +} From 74ec10c39c41d971c272e7271d12902154635fb5 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Sun, 15 Aug 2021 23:12:49 -0500 Subject: [PATCH 19/42] still working on problem --- js.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/js.html b/js.html index d22f471..f5cadbf 100644 --- a/js.html +++ b/js.html @@ -1,6 +1,6 @@ - "use strict" + external.js @@ -31,20 +31,21 @@ var num3 = Number(c); var result = Number(a * 400)+Number(b * 380)+Number(c * 350); alert("Your pay check will be $" + result + " for the hours worked this week"); + console.log("Cost of Rentals."); From 6eba63b95f819109f2503afdd08a1e124989b430 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Mon, 16 Aug 2021 15:03:50 -0500 Subject: [PATCH 20/42] first attemt --- conditional.html | 10 +++++ js.html | 57 +++++++++++++------------ js/conditional.js | 106 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 28 deletions(-) create mode 100644 conditional.html create mode 100644 js/conditional.js diff --git a/conditional.html b/conditional.html new file mode 100644 index 0000000..498b244 --- /dev/null +++ b/conditional.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/js.html b/js.html index f5cadbf..7165c93 100644 --- a/js.html +++ b/js.html @@ -4,6 +4,7 @@ external.js + < - \ No newline at end of file + \ No newline at end of file diff --git a/js/conditional.js b/js/conditional.js new file mode 100644 index 0000000..8317296 --- /dev/null +++ b/js/conditional.js @@ -0,0 +1,106 @@ +"use strict"; + +/* ########################################################################## */ +console.log("It's working") +/** + * TODO: + * Create a function named `analyzeColor` that accepts a string that is a color + * name as input. This function should return a message that related to that + * color. Only worry about the colors defined below, if the color passed is not + * one of the ones defined below, return a message that says so + * + * Example: + * > analyzeColor('blue') // returns "blue is the color of the sky" + * > analyzeColor('red') // returns "Strawberries are red" + * > analyzeColor('cyan') // returns "I don't know anything about cyan" + * + * You should use an if-else-if-else block to return different messages. + * + * Test your function by passing various string literals to it and + * console.logging the function's return value + */ +function analyzeColor (input) { + if (input) { + // code here gets executed if conditional evaluates to true + alert("The ocean appears blue.") + } else if (input) { + //code here gets executed only if condition1 is false *and* condition2 evaluates to true + alert("Your garden roses are a very vivid red.") + } else { + //code here gets executed if neither condition1 nor condition2 evaluate to true + alert("I'm not sure what color that is.") + } +} +// Don't change the next two lines! +// These lines create two variables for you: +// - `colors`: a list of the colors of the rainbow +// - `randomColor`: contains a single random color value from the list (this +// will contain a different color every time the page loads) +var colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; +var randomColor = colors[Math.floor(Math.random() * colors.length)]; +/** + * TODO: + * Pass the `randomColor` variable to your function and console.log the results. + * You should see a different message every time you refresh the page + */ + +/** + * TODO: + * Refactor your above function to use a switch-case statement + */ + +/** + * TODO: + * Prompt the user for a color when the page loads, and pass the input from the + * user to your `analyzeColor` function. Alert the return value from your + * function to show it to the user. + */ + +/* ########################################################################## */ + +/** + * TODO: + * Suppose there's a promotion in Walmart, each customer is given a randomly + * generated "lucky number" between 0 and 5. If your lucky number is 0 you have + * no discount, if your lucky number is 1 you'll get a 10% discount, if it's 2, + * the discount is 25%, if it's 3, 35%, if it's 4, 50%, and if it's 5 you'll get + * all for free!. + * + * Write a function named `calculateTotal` that accepts a lucky number and total + * amount, and returns the discounted price. + * + * Example: + * calculateTotal(0, 100) // returns 100 + * calculateTotal(4, 100) // returns 50 + * calculateTotal(5, 100) // returns 0 + * + * Test your function by passing it various values and checking for the expected + * return value. + */ + +/** + * TODO: + * Uncomment the line below to generate a random number between 0 and 6. + * Prompt the user for their total bill, then use your `calculateTotal` function + * and alerts to display to the user what their lucky number was, what their + * price before the discount was, and what their price after the discount is. + */ +// Generate a random number between 0 and 6 +// var luckyNumber = Math.floor(Math.random() * 6); + +/** + * TODO: + * Write some JavaScript that uses a `confirm` dialog to ask the user if they + * would like to enter a number. If they click 'Ok', prompt the user for a + * number, then use 3 separate alerts to tell the user: + * + * - whether the number is even or odd + * - what the number plus 100 is + * - if the number is negative or positive + * + * if what the user enters is not a number, use an alert to tell them that, and + * do *not* display any of the above information. + * + * Can you refactor your code to use functions? + * HINT: The way we prompt for a value could be improved + */ \ No newline at end of file From 0b275c7c24149d2ef65546e0e7f2ff96fa6f970a Mon Sep 17 00:00:00 2001 From: john alejandro Date: Mon, 16 Aug 2021 16:11:20 -0500 Subject: [PATCH 21/42] 2 --- conditional.html | 2 +- js/conditional.js | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/conditional.html b/conditional.html index 498b244..49f34eb 100644 --- a/conditional.html +++ b/conditional.html @@ -2,7 +2,7 @@ - Title + Conditinal.html diff --git a/js/conditional.js b/js/conditional.js index 8317296..d0fdec4 100644 --- a/js/conditional.js +++ b/js/conditional.js @@ -19,18 +19,20 @@ console.log("It's working") * Test your function by passing various string literals to it and * console.logging the function's return value */ -function analyzeColor (input) { - if (input) { +function analyzeColor(input) { + if (input === "blue") { // code here gets executed if conditional evaluates to true alert("The ocean appears blue.") - } else if (input) { + } else if (input === "red") { //code here gets executed only if condition1 is false *and* condition2 evaluates to true - alert("Your garden roses are a very vivid red.") + alert("Your garden roses are a vivid red.") } else { //code here gets executed if neither condition1 nor condition2 evaluate to true alert("I'm not sure what color that is.") + } } +console.log("The function analyzeColor returns value."); // Don't change the next two lines! // These lines create two variables for you: // - `colors`: a list of the colors of the rainbow @@ -43,13 +45,36 @@ var randomColor = colors[Math.floor(Math.random() * colors.length)]; * Pass the `randomColor` variable to your function and console.log the results. * You should see a different message every time you refresh the page */ +function analyzeColor(input) { + if (input === "blue") { + // code here gets executed if conditional evaluates to true + alert("The ocean appears blue.") + } else if (input === "red") { + //code here gets executed only if condition1 is false *and* condition2 evaluates to true + alert("Your garden roses are a vivid red.") + } else { + //code here gets executed if neither condition1 nor condition2 evaluate to true + alert("I'm not sure what color that is.") + } +} +console.log("The function analyzeColor returns different values."); /** * TODO: * Refactor your above function to use a switch-case statement */ - +switch (analyzeColor) { + case "blue": + alert("The ocean appears blue."); + break; + case "red": + alert("Your garden roses are a vivid red."); + break; + default: + alert("I'm not sure what color that is."); + break; /** + * * TODO: * Prompt the user for a color when the page loads, and pass the input from the * user to your `analyzeColor` function. Alert the return value from your From a64f90e375c3704d0b1d2862b7d44451a23345b0 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Mon, 16 Aug 2021 16:59:09 -0500 Subject: [PATCH 22/42] moving along on problems --- js/conditional.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/js/conditional.js b/js/conditional.js index d0fdec4..67c5947 100644 --- a/js/conditional.js +++ b/js/conditional.js @@ -21,13 +21,10 @@ console.log("It's working") */ function analyzeColor(input) { if (input === "blue") { - // code here gets executed if conditional evaluates to true alert("The ocean appears blue.") } else if (input === "red") { - //code here gets executed only if condition1 is false *and* condition2 evaluates to true alert("Your garden roses are a vivid red.") } else { - //code here gets executed if neither condition1 nor condition2 evaluate to true alert("I'm not sure what color that is.") } @@ -47,13 +44,10 @@ var randomColor = colors[Math.floor(Math.random() * colors.length)]; */ function analyzeColor(input) { if (input === "blue") { - // code here gets executed if conditional evaluates to true alert("The ocean appears blue.") } else if (input === "red") { - //code here gets executed only if condition1 is false *and* condition2 evaluates to true alert("Your garden roses are a vivid red.") } else { - //code here gets executed if neither condition1 nor condition2 evaluate to true alert("I'm not sure what color that is.") } @@ -73,6 +67,8 @@ switch (analyzeColor) { default: alert("I'm not sure what color that is."); break; +} +console.log("Switch-case is working"); /** * * TODO: @@ -80,7 +76,8 @@ switch (analyzeColor) { * user to your `analyzeColor` function. Alert the return value from your * function to show it to the user. */ - +var analyzeColor = prompt("Pick a color?"); +alert("You picked, " + analyzeColor + " that's a nice color."); /* ########################################################################## */ /** @@ -102,6 +99,10 @@ switch (analyzeColor) { * Test your function by passing it various values and checking for the expected * return value. */ +function calculateTotal(totalAmount,luckyDiscount) { + return totalAmount-(totalAmount * luckyDiscount); + +} /** * TODO: From 6337a3d879806c5d7a1bd3ec540f9f15a70d248d Mon Sep 17 00:00:00 2001 From: john alejandro Date: Tue, 17 Aug 2021 11:10:13 -0500 Subject: [PATCH 23/42] loop --- js/loops.js | 3 +++ loops.html | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 js/loops.js create mode 100644 loops.html diff --git a/js/loops.js b/js/loops.js new file mode 100644 index 0000000..bd26caf --- /dev/null +++ b/js/loops.js @@ -0,0 +1,3 @@ +while( i <== 10) { + console.log("Count to 10"); +} diff --git a/loops.html b/loops.html new file mode 100644 index 0000000..405c49f --- /dev/null +++ b/loops.html @@ -0,0 +1,10 @@ + + + + + Loops + + + + + \ No newline at end of file From 6e42e7911924f113629a74cb183c7d8865e30f3e Mon Sep 17 00:00:00 2001 From: john alejandro Date: Tue, 17 Aug 2021 11:16:50 -0500 Subject: [PATCH 24/42] test commit --- js/loops.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/loops.js b/js/loops.js index bd26caf..daefc9d 100644 --- a/js/loops.js +++ b/js/loops.js @@ -1,3 +1,7 @@ -while( i <== 10) { +console.log("Loops is working."); +) +var i =0; +while( i < 10) { console.log("Count to 10"); + i++; } From 598dab8ac96debabb61a8fc23d4735949c035706 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Tue, 17 Aug 2021 11:22:54 -0500 Subject: [PATCH 25/42] test2 --- js/loops.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/loops.js b/js/loops.js index daefc9d..f622e7a 100644 --- a/js/loops.js +++ b/js/loops.js @@ -1,7 +1,12 @@ -console.log("Loops is working."); +console.log("Loops is working.") ) var i =0; while( i < 10) { console.log("Count to 10"); i++; } + var i i = 10: +while ( i > 10) { + i--: +console.log("Hey there") +} \ No newline at end of file From 150e704a28b1a9bf74993a5365064f7bcd45a905 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Tue, 17 Aug 2021 11:39:26 -0500 Subject: [PATCH 26/42] new attempt --- js/loops.js | 4 ++-- loops.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/loops.js b/js/loops.js index f622e7a..2f15fad 100644 --- a/js/loops.js +++ b/js/loops.js @@ -1,5 +1,5 @@ console.log("Loops is working.") -) + var i =0; while( i < 10) { console.log("Count to 10"); @@ -8,5 +8,5 @@ while( i < 10) { var i i = 10: while ( i > 10) { i--: -console.log("Hey there") +console.log("Hey there": + i); } \ No newline at end of file diff --git a/loops.html b/loops.html index 405c49f..5d2f57a 100644 --- a/loops.html +++ b/loops.html @@ -5,6 +5,6 @@ Loops - + \ No newline at end of file From 4d528dd6e9a9ca105f5fae6a227a211ff3f0958e Mon Sep 17 00:00:00 2001 From: john alejandro Date: Tue, 17 Aug 2021 19:20:10 -0500 Subject: [PATCH 27/42] Created loop files --- js/break_and_continue.js | 1 + js/for_loops.js | 7 +++++++ js/loops.js | 26 ++++++++++++++++---------- js/while.js | 1 + loops.html | 5 ++++- 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 js/break_and_continue.js create mode 100644 js/for_loops.js create mode 100644 js/while.js diff --git a/js/break_and_continue.js b/js/break_and_continue.js new file mode 100644 index 0000000..ebfc9fb --- /dev/null +++ b/js/break_and_continue.js @@ -0,0 +1 @@ +console.log("Break_and_Continue.js is in the \"House\".") \ No newline at end of file diff --git a/js/for_loops.js b/js/for_loops.js new file mode 100644 index 0000000..5abb984 --- /dev/null +++ b/js/for_loops.js @@ -0,0 +1,7 @@ +console.log("Yup, \"fruit\" for_loops.js is up and running.") +function showMultiplicationTable(num) { + for ( num ; num <= 10; num++) { + console.log("Here are multiplication Tables up to 10."); + } +} + diff --git a/js/loops.js b/js/loops.js index 2f15fad..9352bb0 100644 --- a/js/loops.js +++ b/js/loops.js @@ -1,12 +1,18 @@ console.log("Loops is working.") -var i =0; -while( i < 10) { - console.log("Count to 10"); - i++; -} - var i i = 10: -while ( i > 10) { - i--: -console.log("Hey there": + i); -} \ No newline at end of file +// var i = 0; +// while( i <= 30) { +// console.log("Count to " + i ); +// i++; +// } +// var i = 10; +// while ( i <= 10) { +// console.log("Count up from " + i); +// i--; +// } +// var x = 0; +// while (true) { +// if (x === 5); +// alert(" Never ending song." + x.length); +// break; +// } \ No newline at end of file diff --git a/js/while.js b/js/while.js new file mode 100644 index 0000000..e33d686 --- /dev/null +++ b/js/while.js @@ -0,0 +1 @@ +console.log("While you were waiting.") \ No newline at end of file diff --git a/loops.html b/loops.html index 5d2f57a..602b9e6 100644 --- a/loops.html +++ b/loops.html @@ -5,6 +5,9 @@ Loops - + + + + \ No newline at end of file From e6ef35186da19d427881414e088a6f320a1f2dea Mon Sep 17 00:00:00 2001 From: john alejandro Date: Tue, 17 Aug 2021 23:15:22 -0500 Subject: [PATCH 28/42] Solved showMultiplication promblem --- js/for_loops.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/for_loops.js b/js/for_loops.js index 5abb984..96b1eaa 100644 --- a/js/for_loops.js +++ b/js/for_loops.js @@ -1,7 +1,9 @@ console.log("Yup, \"fruit\" for_loops.js is up and running.") -function showMultiplicationTable(num) { - for ( num ; num <= 10; num++) { - console.log("Here are multiplication Tables up to 10."); + +function showMultiplicationTable(x) { + for ( var i = 1; i <= 10; i++) { + for ( var j = 1; j <= 10; j++) + console.log( x + " x " + i + " = " + i*x) ; } } From 81136023214f048ff29eea9b7a26eb3179700867 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Tue, 17 Aug 2021 23:18:44 -0500 Subject: [PATCH 29/42] Correct showMultiplication without extra code line --- js/for_loops.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/for_loops.js b/js/for_loops.js index 96b1eaa..d225838 100644 --- a/js/for_loops.js +++ b/js/for_loops.js @@ -2,7 +2,6 @@ console.log("Yup, \"fruit\" for_loops.js is up and running.") function showMultiplicationTable(x) { for ( var i = 1; i <= 10; i++) { - for ( var j = 1; j <= 10; j++) console.log( x + " x " + i + " = " + i*x) ; } } From c17d987720bbb3f831f1faf0ccf66a7c5736c6d5 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 08:45:59 -0500 Subject: [PATCH 30/42] oddEven Random Number Code --- js/for_loops.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/js/for_loops.js b/js/for_loops.js index d225838..d21fb1f 100644 --- a/js/for_loops.js +++ b/js/for_loops.js @@ -1,8 +1,18 @@ console.log("Yup, \"fruit\" for_loops.js is up and running.") -function showMultiplicationTable(x) { - for ( var i = 1; i <= 10; i++) { - console.log( x + " x " + i + " = " + i*x) ; +// function showMultiplicationTable(x) { +// for ( var i = 1; i <= 10; i++) { +// console.log( x + " x " + i + " = " + i*x) ; +// } +// } + +function oddRandomNumber() { + for ( var i = 20; i <= 200; i++) { + if ( i % 3 === 0) + console.log(i + " is odd."); + else if (i % 2 === 0) + console.log(i + " is even."); } } + From 006339b964b22baa8a165259559290a67bfe7e51 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 10:06:05 -0500 Subject: [PATCH 31/42] First attemt at complete for loop questions. --- js/for_loops.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/js/for_loops.js b/js/for_loops.js index d21fb1f..459a386 100644 --- a/js/for_loops.js +++ b/js/for_loops.js @@ -6,13 +6,28 @@ console.log("Yup, \"fruit\" for_loops.js is up and running.") // } // } -function oddRandomNumber() { - for ( var i = 20; i <= 200; i++) { +function oddEvenRandomNumber() { + for ( var i = 19; i <200; i++) { if ( i % 3 === 0) console.log(i + " is odd."); else if (i % 2 === 0) console.log(i + " is even."); } } +// oddEvenRandomNumber() +function numberPyramid() { + for ( var i = 1; i <= 9; i++) { + console.log(i + i); + } +} + +// numberPyramid() + +function countDown() { + for (var i = 100; i >= 5; i-- ) + console.log (i) +} + +// countDown() \ No newline at end of file From d4311e0ed1b009f5ded3f59077dbb0df44a5faa1 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 11:04:58 -0500 Subject: [PATCH 32/42] Final result with help --- js/break_and_continue.js | 13 ++++++++++++- js/for_loops.js | 8 ++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/js/break_and_continue.js b/js/break_and_continue.js index ebfc9fb..7135e8d 100644 --- a/js/break_and_continue.js +++ b/js/break_and_continue.js @@ -1 +1,12 @@ -console.log("Break_and_Continue.js is in the \"House\".") \ No newline at end of file +console.log("Break_and_Continue.js is in the \"House\".") + +var x = 0; + +var prompt("Pick a number between 1 and 50?"); +while (false) { + x++; + if ( x % 2 === 0) { + alert(" Pick another number.") + else ( x % 3 ===) + } +} \ No newline at end of file diff --git a/js/for_loops.js b/js/for_loops.js index 459a386..4b61890 100644 --- a/js/for_loops.js +++ b/js/for_loops.js @@ -18,7 +18,11 @@ function oddEvenRandomNumber() { function numberPyramid() { for ( var i = 1; i <= 9; i++) { - console.log(i + i); + var number = ""; + for ( var j =1; j <= i; j++) { + number = number + i.toString() + } + console.log(number); } } @@ -26,7 +30,7 @@ function numberPyramid() { // numberPyramid() function countDown() { - for (var i = 100; i >= 5; i-- ) + for (var i = 100; i >= 5; i=i-5 ) console.log (i) } From 585bf4aa59301f9cae13ca8ead0356b08e5714e5 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 11:08:27 -0500 Subject: [PATCH 33/42] Calling all Functions added --- js/for_loops.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/js/for_loops.js b/js/for_loops.js index 4b61890..2a77379 100644 --- a/js/for_loops.js +++ b/js/for_loops.js @@ -1,11 +1,10 @@ console.log("Yup, \"fruit\" for_loops.js is up and running.") -// function showMultiplicationTable(x) { -// for ( var i = 1; i <= 10; i++) { -// console.log( x + " x " + i + " = " + i*x) ; -// } -// } - +function showMultiplicationTable(x) { + for ( var i = 1; i <= 10; i++) { + console.log( x + " x " + i + " = " + i*x) ; + } +}showMultiplicationTable(7) function oddEvenRandomNumber() { for ( var i = 19; i <200; i++) { if ( i % 3 === 0) @@ -14,7 +13,7 @@ function oddEvenRandomNumber() { console.log(i + " is even."); } } -// oddEvenRandomNumber() +oddEvenRandomNumber() function numberPyramid() { for ( var i = 1; i <= 9; i++) { @@ -27,7 +26,7 @@ function numberPyramid() { } } -// numberPyramid() +numberPyramid() function countDown() { for (var i = 100; i >= 5; i=i-5 ) From 9d7a05a1bc00bc65b5bfaaa9b6136838a79a3a4d Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 16:29:12 -0500 Subject: [PATCH 34/42] closing out --- js/break_and_continue.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/js/break_and_continue.js b/js/break_and_continue.js index 7135e8d..7547da2 100644 --- a/js/break_and_continue.js +++ b/js/break_and_continue.js @@ -1,12 +1,8 @@ console.log("Break_and_Continue.js is in the \"House\".") -var x = 0; - -var prompt("Pick a number between 1 and 50?"); -while (false) { - x++; - if ( x % 2 === 0) { - alert(" Pick another number.") - else ( x % 3 ===) - } -} \ No newline at end of file + + + var prompt ("Pick an odd number between 1 and 50?"); + + + From 09bc06216c95c2ceee9a9d0f9237388177d9ff75 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 16:34:53 -0500 Subject: [PATCH 35/42] New practice Code Folder --- Practice_Code.html | 11 +++++++++++ js/Practice_Code.js | 1 + 2 files changed, 12 insertions(+) create mode 100644 Practice_Code.html create mode 100644 js/Practice_Code.js diff --git a/Practice_Code.html b/Practice_Code.html new file mode 100644 index 0000000..41e843a --- /dev/null +++ b/Practice_Code.html @@ -0,0 +1,11 @@ + + + + + Practice Code + + + + + + \ No newline at end of file diff --git a/js/Practice_Code.js b/js/Practice_Code.js new file mode 100644 index 0000000..f6db432 --- /dev/null +++ b/js/Practice_Code.js @@ -0,0 +1 @@ +console.log("Practice Code Open and Running"); \ No newline at end of file From ef5b435ae0a278a35e128a7ed729c90352107aca Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 17:39:27 -0500 Subject: [PATCH 36/42] Working thru trying examples to better undersatnd --- js/Practice_Code.js | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/js/Practice_Code.js b/js/Practice_Code.js index f6db432..08bba1e 100644 --- a/js/Practice_Code.js +++ b/js/Practice_Code.js @@ -1 +1,41 @@ -console.log("Practice Code Open and Running"); \ No newline at end of file +"use strict"; +console.log("Practice Code Open and Running"); + +// console.log("Hello from Practice Code JS!"); +// var myStr =45; +// only numbers work in var, no symbols or letters. Show up as undefined. + +// console.log(myStr) +// console.log will return whatever you type in in quotes as well as any input or stated var or defined item + +// var howmanyPets =2; +// console.log(howmanyPets) + +// alert("Wow, this is nice when you know what your doing!"); +// alert("Do you feel like your understand alerts and how they work?"); + +// var userconfirm = confirm("Do you want to remain logged on?"); +// // useconfirm = confirm -Requires input from user in form of clicking cancel or ok. +// // Both alert and userconfirm remove from screen once an action is taken in box. + +// alert ("The user selected: " + userconfirm) +// // By adding concatenation(+) to alert and enetring input in this case userconfirm you get a true statement. Boolean -True / False + +// var userLunch = prompt("What did you have for lunch today?") +// // prompt is always proceeded by a var "name" and can be followed up with alert and var "name" input +// alert("The user had " + userLunch + " for lunch!") +// function sayHello(name) { +// return "Hello, " + name; +// // all functions must be in format shown with () and {} need a return statement +// } +// console.log(sayHello("codeup")); +// in order to run or call function - you can use console.log with ( "function name ( and whatever you want it to say")) +// function myPets(name) { +// return "Their names are, " + name; +// } +// console.log(myPets("Bandit and Coco Chanel")); + +function favMovie(name) { + return "My favorite movie is, " + favMovie; +} +console.log(favMovie("The Big Blue")); \ No newline at end of file From 3992f9fecb40abc3a273d76ef04e650da3269999 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 18:01:17 -0500 Subject: [PATCH 37/42] Time to move on to next item --- js/Practice_Code.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/js/Practice_Code.js b/js/Practice_Code.js index 08bba1e..ae0aab7 100644 --- a/js/Practice_Code.js +++ b/js/Practice_Code.js @@ -36,6 +36,36 @@ console.log("Practice Code Open and Running"); // console.log(myPets("Bandit and Coco Chanel")); function favMovie(name) { - return "My favorite movie is, " + favMovie; + return "My favorite movie is, " + name; } -console.log(favMovie("The Big Blue")); \ No newline at end of file +console.log(favMovie("The Big Blue")); +// console.log must be outside {} of function brackets in order to work. + +function keepTrying(name) { + return "Do not give up," + name; +} + console.log(keepTrying(" it will get better.")); +// console.log must be outside {} of function brackets in order to work. + +function color(name) { + return "My favorite color is, " + name; +} +console.log(color( "red.")); +// console.log must be outside {} of function brackets in order to work. + +function underStand(name) { + return "Are you starting to understand, " + name; +} +console.log(underStand("functions?")); +// console.log must be outside {} of function brackets in order to work. + +function oneMore(name) { + return "Keep it up don't give up on understanding, " + name; +} +console.log(oneMore("functions.")); +// console.log must be outside {} of function brackets in order to work. + +function noMistakes(name) { + return "You almost got it with out any " + name; +} +console.log(noMistakes("mistakes.")); \ No newline at end of file From aac015b2cd2c52f6854b97d28465c292d4107ef9 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 18:20:37 -0500 Subject: [PATCH 38/42] get it right --- js/Practice_Code.js | 93 ++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/js/Practice_Code.js b/js/Practice_Code.js index ae0aab7..f17d28a 100644 --- a/js/Practice_Code.js +++ b/js/Practice_Code.js @@ -24,48 +24,61 @@ console.log("Practice Code Open and Running"); // var userLunch = prompt("What did you have for lunch today?") // // prompt is always proceeded by a var "name" and can be followed up with alert and var "name" input // alert("The user had " + userLunch + " for lunch!") -// function sayHello(name) { -// return "Hello, " + name; +function sayHello(name) { + return "Hello, " + name; // // all functions must be in format shown with () and {} need a return statement -// } -// console.log(sayHello("codeup")); +} + console.log(sayHello("codeup")); +var helloMessage = sayHello("John"); + console.log(helloMessage); +var myName = "John Alejandro"; + console.log(sayHello(myName)) // in order to run or call function - you can use console.log with ( "function name ( and whatever you want it to say")) -// function myPets(name) { -// return "Their names are, " + name; +// function myPets(name) { +// return "Their names are, " + name; // } -// console.log(myPets("Bandit and Coco Chanel")); - -function favMovie(name) { - return "My favorite movie is, " + name; -} -console.log(favMovie("The Big Blue")); -// console.log must be outside {} of function brackets in order to work. - -function keepTrying(name) { - return "Do not give up," + name; -} - console.log(keepTrying(" it will get better.")); -// console.log must be outside {} of function brackets in order to work. - -function color(name) { - return "My favorite color is, " + name; -} -console.log(color( "red.")); -// console.log must be outside {} of function brackets in order to work. - -function underStand(name) { - return "Are you starting to understand, " + name; -} -console.log(underStand("functions?")); -// console.log must be outside {} of function brackets in order to work. +// // console.log(myPets("Bandit and Coco Chanel")); +// +// function favMovie(name) { +// return "My favorite movie is, " + name; +// } +// console.log(favMovie("The Big Blue")); +// // console.log must be outside {} of function brackets in order to work. +// +// function keepTrying(name) { +// return "Do not give up," + name; +// } +// console.log(keepTrying(" it will get better.")); +// // console.log must be outside {} of function brackets in order to work. +// +// function color(name) { +// return "My favorite color is, " + name; +// } +// console.log(color( "red.")); +// // console.log must be outside {} of function brackets in order to work. +// +// function underStand(name) { +// return "Are you starting to understand, " + name; +// } +// console.log(underStand("functions?")); +// // console.log must be outside {} of function brackets in order to work. +// +// function oneMore(name) { +// return "Keep it up don't give up on understanding, " + name; +// } +// console.log(oneMore("functions.")); +// // console.log must be outside {} of function brackets in order to work. +// +// function noMistakes(name) { +// return "You almost got it with out any " + name; +// } +// console.log(noMistakes("mistakes.")); +// // console.log must be outside {} of function brackets in order to work. -function oneMore(name) { - return "Keep it up don't give up on understanding, " + name; -} -console.log(oneMore("functions.")); -// console.log must be outside {} of function brackets in order to work. +var random = Math.floor((Math.random() * 3) + 1); -function noMistakes(name) { - return "You almost got it with out any " + name; -} -console.log(noMistakes("mistakes.")); \ No newline at end of file + function isTwo(number) { + console.log("Our number is: " + number); + return number === 2; + } + console.log(isTwo(random)); \ No newline at end of file From 938156294c3a1238a7d81df2f43108845188cfc9 Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 18:58:18 -0500 Subject: [PATCH 39/42] understanding it a little better --- js/Practice_Code.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/js/Practice_Code.js b/js/Practice_Code.js index f17d28a..aa00f8d 100644 --- a/js/Practice_Code.js +++ b/js/Practice_Code.js @@ -22,17 +22,20 @@ console.log("Practice Code Open and Running"); // // By adding concatenation(+) to alert and enetring input in this case userconfirm you get a true statement. Boolean -True / False // var userLunch = prompt("What did you have for lunch today?") -// // prompt is always proceeded by a var "name" and can be followed up with alert and var "name" input +// // prompt is always proceeded by a var "name" and can be followed up with alert "comments" and + var "name" input // alert("The user had " + userLunch + " for lunch!") function sayHello(name) { return "Hello, " + name; // // all functions must be in format shown with () and {} need a return statement } console.log(sayHello("codeup")); + var helloMessage = sayHello("John"); console.log(helloMessage); + var myName = "John Alejandro"; console.log(sayHello(myName)) + // in order to run or call function - you can use console.log with ( "function name ( and whatever you want it to say")) // function myPets(name) { // return "Their names are, " + name; @@ -80,5 +83,23 @@ var random = Math.floor((Math.random() * 3) + 1); function isTwo(number) { console.log("Our number is: " + number); return number === 2; - } - console.log(isTwo(random)); \ No newline at end of file +} + // console.log(isTwo(random)); +// console.log inside function {} calls function and in this case the return is a boolean value second console.log calls function with input + +// function calculateTip(tipPercentage,total){ +// return tipPercentage * total; +// } +// console.log(calculateTip(.2,20)); +// console.log(calculateTip(.5,50)); +// console.log(calculateTip(.35,20)); +// +// var userBill = prompt("How much was your Bill?"); +// var userTip = prompt("How much would you like to tip in a whole number?") / 100; +// // userTip = userTip / 100; +// alert("Thank you so much for your patronage - You will be tipping : $" + calculateTip(userTip,userBill)); + +function applyDiscount(originalPrice,discountpercent){ + return originalPrice -(originalPrice * discountpercent); +} + From 83ff60f05c8ef5a20af9471add14541d5da6090b Mon Sep 17 00:00:00 2001 From: john alejandro Date: Wed, 18 Aug 2021 19:46:22 -0500 Subject: [PATCH 40/42] switch back to master branch --- js.html | 11 +++++------ js/Practice_Code.js | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/js.html b/js.html index 7165c93..772610c 100644 --- a/js.html +++ b/js.html @@ -1,5 +1,4 @@ -"use strict" @@ -18,7 +17,7 @@ // console.log('The user entered: ' + userInput); var num3 = Number(c); var result = Number(a)+Number(b)+Number(c); - alert("Your total is $" + result * 3 ); + alert("Your total today for your movie rentals is $" + result * 3 ); - \ No newline at end of file + + + diff --git a/js/Practice_Code.js b/js/Practice_Code.js index 97a1702..448c417 100644 --- a/js/Practice_Code.js +++ b/js/Practice_Code.js @@ -1,18 +1,18 @@ "use strict"; console.log("Practice Code Open and Running"); -// console.log("Hello from Practice Code JS!"); -// var myStr =45; +console.log("Hello from Practice Code JS!"); +var myStr =45; // only numbers work in var, no symbols or letters. Show up as undefined. -// console.log(myStr) +console.log(myStr) // console.log will return whatever you type in in quotes as well as any input or stated var or defined item -// var howmanyPets =2; -// console.log(howmanyPets) +var howmanyPets =2; +console.log(howmanyPets) -// alert("Wow, this is nice when you know what your doing!"); -// alert("Do you feel like your understand alerts and how they work?"); +alert("Wow, this is nice when you know what your doing!"); +alert("Do you feel like your understand alerts and how they work?"); var userconfirm = confirm("Do you want to remain logged on?"); // useconfirm = confirm -Requires input from user in form of clicking cancel or ok. @@ -103,5 +103,4 @@ function applyDiscount(originalPrice,discountpercent){ return originalPrice -(originalPrice * discountpercent); } // function isArray(input) { -// return Array == 0; -} +// return Array == 0;}