diff --git a/Fortune1 b/Fortune1 new file mode 100644 index 0000000..566ebd6 --- /dev/null +++ b/Fortune1 @@ -0,0 +1,12 @@ +const ar =[23,55,103,4,70] +const largest =maxValue(ar) +function maxValue(arr){ +let output; +if (arr === undefined || arr.length == 0) { +output = "Array is empty please add an item to the array" +} else { + let biggestNumber =Math.max(...arr) +output =`the largest number in the array is ${biggestNumber}` +} +console.log(output) +} diff --git a/MaxValue.js b/MaxValue.js new file mode 100644 index 0000000..566ebd6 --- /dev/null +++ b/MaxValue.js @@ -0,0 +1,12 @@ +const ar =[23,55,103,4,70] +const largest =maxValue(ar) +function maxValue(arr){ +let output; +if (arr === undefined || arr.length == 0) { +output = "Array is empty please add an item to the array" +} else { + let biggestNumber =Math.max(...arr) +output =`the largest number in the array is ${biggestNumber}` +} +console.log(output) +}