From 9fa7ea65d89567f5bb6c57bd423d8361fae6d4cc Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 12:32:20 -0400 Subject: [PATCH 1/8] solution for problem 1 --- pset1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pset1.js b/pset1.js index 9261c6d..5a5e219 100644 --- a/pset1.js +++ b/pset1.js @@ -9,10 +9,13 @@ if that number is > 100, should return NaN if invalid input given, return -1 ******************/ + function myAge( ageNow, numYears ) { - + +return ageNow + numYears } +console.log (myAge(26, 4)); /****************** From 31ef9e3c68fdb904db86fefa3170e2c7193fc1fa Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 14:25:38 -0400 Subject: [PATCH 2/8] completed problem2 --- pset1.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pset1.js b/pset1.js index 5a5e219..d3e3cec 100644 --- a/pset1.js +++ b/pset1.js @@ -15,8 +15,7 @@ function myAge( ageNow, numYears ) { return ageNow + numYears } -console.log (myAge(26, 4)); - +//console.log (myAge(26, 4)) /****************** Concatenate Strings @@ -33,10 +32,11 @@ Concatenating string variables ******************/ function myConcatenate( firstStr, secondStr, thirdStr ) { - + return `${firstStr} ${secondStr} ${thirdStr}` } myConcatenate('I', 'am', 'iron man'); // 'I am iron man' +console.log (myConcatenate('I', 'am', 'iron man')) /****************** Subtract Function From 820df992337b808e04cbcb72edacc660d0953450 Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 14:46:11 -0400 Subject: [PATCH 3/8] problem 3 --- pset1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pset1.js b/pset1.js index d3e3cec..984262c 100644 --- a/pset1.js +++ b/pset1.js @@ -48,8 +48,9 @@ Ensure that both of the inputs are numbers ******************/ function subtract(a,b) { - + return a - b } +console.log(subtract(10, 5)); /****************** Area of A Circle From 744c8848653b74533d72d3e382119f64d2d30a6a Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 15:08:24 -0400 Subject: [PATCH 4/8] problem 4 --- pset1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pset1.js b/pset1.js index 984262c..6fc1e03 100644 --- a/pset1.js +++ b/pset1.js @@ -65,9 +65,12 @@ A = π * r2, where is π is Pi and r is the radius squared function areaOfaCircle(radius){ - + console.log('radius is...', radius); + const area = Math.PI * radius ** 2; + return area; } +console.log(areaOfaCircle(1), 3.14159); /****************** Temperature Converter Fahrenheit to Celsius From b00e6c75342c95651e36e493a87c31ad24cc08ce Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 15:25:29 -0400 Subject: [PATCH 5/8] convert fahrenheit to celsius --- pset1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pset1.js b/pset1.js index 6fc1e03..8480761 100644 --- a/pset1.js +++ b/pset1.js @@ -81,7 +81,10 @@ Now store a fahrenheit temperature into a variable. Convert it to celsius and output "NN°F is NN°C." ******************/ - +function fahrenheitToCelsius(fTemp){ + return `${fTemp} degree F is ${(fTemp -32) * 1.8} degree C` +} +console.log(fahrenheitToCelsius(32)); /****************** Temperature Converter Celsius to Fahrenheit From 122d85fa2dfe0808586191025f4d1015a2e5cd40 Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 15:32:16 -0400 Subject: [PATCH 6/8] convert celcius to fahrenheit --- pset1.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pset1.js b/pset1.js index 8480761..d186797 100644 --- a/pset1.js +++ b/pset1.js @@ -96,6 +96,10 @@ Store a celsius temperature into a variable. Convert it to fahrenheit and output "NN°C is NN°F". ******************/ +function celsiusToFahrenheit(cTemp){ + return `${cTemp} degree C is ${(cTemp *9/5) + 32} degree F` +} +console.log(celsiusToFahrenheit(0)); /****************** Is it the weekend? From 6f47a9c039f814bba28e43b201972dfb3a8ed8ae Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 15:39:10 -0400 Subject: [PATCH 7/8] absolute number probelem --- pset1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pset1.js b/pset1.js index d186797..c2c640b 100644 --- a/pset1.js +++ b/pset1.js @@ -129,7 +129,10 @@ The function should return the absolute value of the number The absolute value of a negative number is the positive version of that same number, and the absolute value of a positive number (or zero) is that number itself. ******************/ - +function absolute(num){ + return Math.abs(num) +} +console.log(absolute(-6)); /****************** Create a function that counts the number of characters in your name From aa6079d604f8747da8c3d446608c27e70550781b Mon Sep 17 00:00:00 2001 From: Chuyun Huang Date: Sun, 7 Oct 2018 15:54:51 -0400 Subject: [PATCH 8/8] count the number of characters --- pset1.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pset1.js b/pset1.js index c2c640b..194aa16 100644 --- a/pset1.js +++ b/pset1.js @@ -145,4 +145,8 @@ return the number of characters in the string call function 'countChars' ******************/ - +function countCharacter(string){ + return `hi my length is : ${string.length}`; +} + +console.log(countCharacter("Chuyun"));