JavaScript
This answer is obvious but still, im giving a shot at it :
var arrName = ["Jeff", "Emma", "Steve", "Julie"];
randName.call.apply(getName, arrName)
function randName(){
var names = Array.prototype.slice.call(arguments)
this.call(arrName[Mathnames[Math.floor(Math.random() * arrNamenames.length)]);
}
function getName(){
alert(this)
}
Poor Jeff, he will always have to buy the drinks.
The trick here is in the
call.apply()
. The function being called is not therandName
, but directlygetName
where thisthis
will be equal to the first cell in the array.