how to return multiple values from a function as a object in js code example
Example 1: can you return 2 values in javascript object
function friends(){
var names = {
closeCircle: ['bebo','eli','matthew'],
outerCircle:['vierie','nate','james','george'],
};
return [names.closeCircle[0], names.closeCircle[2]]
}
Example 2: javascript return multiple values from a function
function getTopTwoColors() {
return ["blue", "pink"];
}
var topTwoColors=getTopTwoColors();
var firstValue=topTwoColors[0];
var secondValue=topTwoColors[1];