Skip to content

Instantly share code, notes, and snippets.

@benstone1
Created July 15, 2016 01:00
Show Gist options
  • Save benstone1/48829266228ecf63bffafffaa8ea6183 to your computer and use it in GitHub Desktop.
Save benstone1/48829266228ecf63bffafffaa8ea6183 to your computer and use it in GitHub Desktop.
var myWords = ["Hello!", "What", "is", "your", "name?", "Functions", "are", "cool!"]
var concatenateArray = function(arr){
var str = ""
for (var i = 0; i < arr.length;i++){
var currentString = arr[i]
str += currentString
str += " "
}
return "My string is: " + str
}
console.log( concatenateArray(myWords) )
function findMax(inputArray){
var currentMax = inputArray[0]
for (var i = 0;i < inputArray.length; i++ ){
var currentNumber = inputArray[i]
if (currentNumber > currentMax){
currentMax = currentNumber
}
}
return currentMax
}
console.log( findMax([3,9,2,45.23,-234,15,1,19,24542243]) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment