Skip to main content
added 8 characters in body
Source Link

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 the randName, but directly getName where this this will be equal to the first cell in the array.

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(){
    Array.prototype.slice.call(arguments)
    
    this.call(arrName[Math.floor(Math.random() * arrName.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 the randName, but directly getName where this this will be equal to the first cell in the array.

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(names[Math.floor(Math.random() * names.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 the randName, but directly getName where this this will be equal to the first cell in the array.

Source Link

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(){
    Array.prototype.slice.call(arguments)
    
    this.call(arrName[Math.floor(Math.random() * arrName.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 the randName, but directly getName where this this will be equal to the first cell in the array.