@@ -6,6 +6,14 @@ const getBiggest = (x, y) => {
66} ;
77
88const greeting = ( language ) => {
9+ if ( language === 'German' ) {
10+ return ( 'Guten Tag!' ) ;
11+ } else if ( language === 'English' ) {
12+ return ( 'Hello!' ) ;
13+ } else if ( language === 'Spanish' ) {
14+ return ( 'Hola!' ) ;
15+ }
16+ return ( 'Hello!' ) ;
917 // return a greeting for three different languages:
1018 // language: 'German' -> 'Guten Tag!'
1119 // language: 'English' -> 'Hello!'
@@ -19,6 +27,10 @@ const isTenOrFive = (num) => {
1927} ;
2028
2129const isInRange = ( num ) => {
30+ if ( num < 50 && num > 20 ) {
31+ return true ;
32+ }
33+ return false ;
2234 // return true if num is less than 50 and greater than 20
2335} ;
2436
@@ -32,6 +44,14 @@ const isInteger = (num) => {
3244} ;
3345
3446const fizzBuzz = ( num ) => {
47+ if ( num % 3 === 0 && num % 5 === 0 ) {
48+ return ( 'fizzbuzz' ) ;
49+ } else if ( num % 3 === 0 ) {
50+ return ( 'fizz' ) ;
51+ } else if ( num % 5 === 0 ) {
52+ return ( 'buzz' ) ;
53+ }
54+ return num ;
3555 // if num is divisible by 3 return 'fizz'
3656 // if num is divisible by 5 return 'buzz'
3757 // if num is divisible by 3 & 5 return 'fizzbuzz'
@@ -47,6 +67,7 @@ const isPrime = (num) => {
4767} ;
4868
4969const returnFirst = ( arr ) => {
70+ return ( arr [ 0 ] ) ;
5071 // return the first item from the array
5172} ;
5273
@@ -55,6 +76,7 @@ const returnLast = (arr) => {
5576} ;
5677
5778const getArrayLength = ( arr ) => {
79+ return ( arr . length ) ;
5880 // return the length of the array
5981} ;
6082
@@ -65,6 +87,8 @@ const incrementByOne = (arr) => {
6587} ;
6688
6789const addItemToArray = ( arr , item ) => {
90+ arr . push ( item ) ;
91+ return ( arr ) ;
6892 // add the item to the end of the array
6993 // return the array
7094} ;
@@ -76,6 +100,7 @@ const addItemToFront = (arr, item) => {
76100} ;
77101
78102const wordsToSentence = ( words ) => {
103+ return ( words . join ( ' ' ) ) ;
79104 // words is an array of strings
80105 // return a string that is all of the words concatenated together
81106 // spaces need to be between each word
@@ -88,6 +113,12 @@ const contains = (arr, item) => {
88113} ;
89114
90115const addNumbers = ( numbers ) => {
116+ let sum = 0 ;
117+ for ( let i = 0 ; i < numbers . length ; i ++ ) {
118+ sum += numbers [ i ] ;
119+ }
120+ numbers = sum ;
121+ return numbers ;
91122 // numbers is an array of integers.
92123 // add all of the integers and return the value
93124} ;
@@ -98,6 +129,8 @@ const averageTestScore = (testScores) => {
98129} ;
99130
100131const largestNumber = ( numbers ) => {
132+ const max = Math . max . apply ( null , numbers ) ;
133+ return max ;
101134 // numbers is an array of integers
102135 // return the largest integer
103136} ;
0 commit comments