Quiz on Literals and Destructuring

Test your understanding of literals and destructuring by attempting this quiz.

1

How can we receive the values returned by the given function in discrete variables? If a value is not returned, let’s use the value 0 instead.

'use strict';
const beforeAndAfter = function(number) {
  if(number < 0) return [];
  if(number === 0) return [1];
  return [number - 1, number + 1]; }
let before = 0;
let after = 0;

//your code goes here
console.log(`${before} and ${after}`); //6 and 8
A)
before, after = beforeAndAfter(7);

B)
[before, after] = beforeAndAfter(7);
C)
before , after = 0 = beforeAndAfter(7);
Question 1 of 50 attempted

Get hands-on with 1200+ tech skills courses.