Question:
Write a function toArray that takes 2 values and returns these values in an array.
Example: toArray(5, 9) should return the array [5, 9].
Answer:
function toArray (a,b) {
let array = [a, b];
return array
}
> declare a function toArray
> it has 2 parameters
> we declare a variable array
> we initialize it with an array that contains the two parameters
> like this [a, b]
> we return the array
No comments:
Post a Comment