Ad
  • Custom User Avatar
  • Custom User Avatar

    this looks very nice

  • Default User Avatar

    Sorry, I seemed to have missed an email detailing this comment.
    Your solution is close but realize that Array.map will return an array with the block executed on each element of the array!
    So you should be making sure to return the sum would be a good idea.

  • Custom User Avatar

    that would only work on modern browsers..

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    .each will only allow 1 parameter for the block so you cannot do: numbers.each {|total, i| total += i}
    You can do numbers.each { |i| total += i } but you'll need total be done in some other way.

  • Custom User Avatar

    Whenever I test my code, I get the following error: Any help would be grealty appreciated.

    +': nil can't be coerced into Fixnum (TypeError) from block in sum'
    from each' from sum'
    from `
    '

    # Sum Numbers
    	def sum(numbers)
    	if (numbers.any?) && (numbers.each { |i| i.class != String} )
    		numbers.each {|total, i| total += i}
    	else
    		return 0
    	end
    	end