diff --git a/js/age.js b/js/age.js index d3f5a12..422e1ef 100644 --- a/js/age.js +++ b/js/age.js @@ -1 +1,71 @@ +const userAge = age => { + switch(age){ + case 0: + return 'infant'; + break; + case 1: + return 'infant'; + break; + case 2: + return 'infant'; + break; + case 3: + return 'toddler'; + break; + case 4: + return 'toddler'; + break; + case 5: + return 'toddler'; + break; + case 6: + return 'child'; + break; + case 7: + return 'child'; + break; + case 8: + return 'child'; + break; + case 9: + return 'child'; + break; + case 10: + return 'child' + break; + case 11: + return 'preteen'; + break; + case 12: + return 'preteen'; + break; + case 13: + return 'preteen'; + break; + case 14: + return 'teen'; + break; + case 15: + return 'teen'; + break; + case 16: + return 'teen'; + break; + case 17: + return 'young adult'; + break; + case 18: + return 'young adult'; + break; + case 19: + return 'young adult'; + break; + case 20: + return 'young adult'; + break; + } +} + +console.log(userAge(5)); + diff --git a/js/larger.js b/js/larger.js index e69de29..b894964 100644 --- a/js/larger.js +++ b/js/larger.js @@ -0,0 +1,9 @@ +function largerNumber(x, y){ + if( x > y){ + console.log(x) + } else{ + console.log(y) + } +} + +console.log(largerNumber(5, 9)); \ No newline at end of file diff --git a/js/pluralizer.js b/js/pluralizer.js index e69de29..490cb13 100644 --- a/js/pluralizer.js +++ b/js/pluralizer.js @@ -0,0 +1,13 @@ +let thing = 'cat'; +let count = 5; +let plural = `${thing}s` + +function pluralizer(thing, count){ + if(count > 1){ + console.log(plural); + } else{ + console.log(thing); + } +} + +console.log(count + " " plural); \ No newline at end of file diff --git a/js/tempConvert.js b/js/tempConvert.js index e69de29..c0dfdbb 100644 --- a/js/tempConvert.js +++ b/js/tempConvert.js @@ -0,0 +1,8 @@ +const Farenheit = 50; + +const Celsius = (Farenheit - 32) * 5/9; + +const Kelvin = Math.floor(Celsius - 273.15); + +console.log(`${Farenheit} degrees Farenheit is ${Celsius} degrees in Celsius and ${Kelvin} degrees in Kelvin`); + diff --git a/js/translator.js b/js/translator.js index e69de29..f0ba8a6 100644 --- a/js/translator.js +++ b/js/translator.js @@ -0,0 +1,43 @@ + +const translator = language => { + switch(language){ + case 'en': + return 'Hello World'; + break; + case 'fr': + return 'Bonjour Le Monde'; + break; + case 'sp': + return 'Hola Mundo'; + break; + + } +} + +console.log(translator('en')); + +// Comparing Arrays +const arr1 = [1, 'a', 3, 'e', 5, 7, 9, 'i']; +const arr2 = [1, 'a', 3, 'e', 5, 7, 9, 'i']; +const arr3 = [1, 'a', 3, 5, 'e', 7, 10, 'i']; +const arr4 = [0, 2, 4, 6]; + +// checking to see if the length of the arrays is the same, if it is then it runs the code block inside +if (arr1.length === arr2.length) { + + //this for loop does for(start iterating at 0; stop iterating once the array ends; iterate) + for (let i = 0; i < arr1.length; i++) { + + //the code block inside checks to see if the variable at arr1[i] is equal to variable at arr2[i] && this iterates over every variable to check to see if the value type is the same in the two arrays. + if (arr1[i] === arr2[i]) { + + // if those conditions are met same value, same data type then it will console log the message below to the terminal + console.log("These arrays the same"); + break + } else{ + + // if those conditions are not met the message below will return ot the console + console.log("These arrays are not the same"); + } + } +}