It might be a super dumb question but I don’t understand how you get an output of 30 in the sum function? Which numbers are you adding up? I was trying to add the total of the sort function + length function which equaled to 27.
Hello! The sum() function adds up its parameters. That means it will add 5, 15 and 10:
sum(x, y, z)
//does the same calculation as:
x + y + z
I hope this helps!
I am still confused
I am getting confused at what they meant by this:
When it says arguments, it means the numbers that are between the parentheses(). So, since it passed in 5, 15, 10, you get 5+15+10=30:
5, 15, 10
sum(5, 10, 15)
all of these are parameters
And the job of the sum function is to add all of its parameters together.
No, since you are only passing values into the function (no variables), you need to use c() to create a vector. Yet since the values 5,15,10 are on their own (there is no c():
c(5, 15, 10)#this is a vector of three values
5, 15, 10#these are just three values
Each value is a separate argument.