1//function that returns multiple values
2function getTopTwoColors() {
3 return ["blue", "pink"];
4}
5var topTwoColors=getTopTwoColors();
6var firstValue=topTwoColors[0]; //get first return value
7var secondValue=topTwoColors[1]; //get second return value
1
2
3
4
5 function getNames() {
6 // get names from the database or API
7 let firstName = 'John',
8 lastName = 'Doe';
9
10 // return values
11 return {
12 firstName,
13 lastName
14 };
15}