1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
You can't return multiple values with multiple variables, but you can do it with an _____. (5 characters) | array | array | |
In the following code, x could be the name of a regular variable, but it is an array name if the function returns an ______. | const x = someFunction(); | array | array |
Fill in the blank to return both multiples. | function returnMultiples() { let firstMultiple = 2 * 2; let secondMultiple = 4 * 4; return ____________; } |
[firstMultiple, secondMultiple] | \[firstMultiple,secondMultiple\] |
Fill in the blank to assign the first element in the array to firstMultiple. | let bothMultiples = returnMultiples(); let firstMultiple = ______________ |
bothMultiples[0]; | bothMultiples\[0\]; |
Code a three-line function with no parameters that returns two string values. Make up everything. | function returnStrings() { return ["Hello ", "world!"]; } |
function[a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]return\[•.*•,•.*•\];[\r\n]} | |
Code two lines. The first line calls a function with no parameters that returns an array. The second line assigns the second array element to a variable. Remember that the preferred keyword for an array is const. Make up everything. | const anArray = someFunction(); let secondValue = anArray[1]; |
const([a-z_$][a-zA-Z0-9_$]*)=[a-z_$][a-zA-Z0-9_$]*\(\);[\r\n]let[a-z_$][a-zA-Z0-9_$]*=\1\[1\]; | |
Code a single line that calls a function (no arguments) and assigns two values returned by the function to an unnamed array. Remember that the preferred keyword for an array is const. Make up everything. | const [firstValue, secondValue] = someFunction(); | const\[[a-z_$][a-zA-Z0-9_$]*,[a-z_$][a-zA-Z0-9_$]*\]=[a-z_$][a-zA-Z0-9_$]*\(\); | |
Code a function (no parameters) that assigns integers to two variables, then returns the two integers to the calling code by specifying the variables. Make up everything. | function returnNumbers() { let x = 1; let y = 2; return [x , y]; } |
function[a-z_$][a-zA-Z0-9_$]*\(\){[\r\n]let([a-z_$][a-zA-Z0-9_$]*)=[-]?(?:[.]\d+|\d+(?:[.]\d*)?);[\r\n]let([a-z_$][a-zA-Z0-9_$]*)=[-]?(?:[.]\d+|\d+(?:[.]\d*)?);[\r\n]return\[\1,\2\];[\r\n]} | |
|
|||
|