Week 14
Quiz 22

Quiz 22: Refresher: Splice

Question 1

Shows 'true'?
JavaScript
const list = ['a', 'bb', 'ccc', 'dddd'];
const result = list.splice(0, 1);
document.writeln(list.length === 3);

Question 2

Shows 'true'?
JavaScript
const list = ['a', 'bb', 'ccc', 'dddd'];
const result = list.splice(1, 0, 'x', 'y');
 
document.writeln(
    list[0] === 'x'
    && list[1] === 'x'
    && list[2] === 'y'
    && list[3] === 'bb'
);

Question 3

Shows 'true'?
JavaScript
const list = ['a', 'bb', 'ccc', 'dddd'];
const result = list.splice(0, 0, 'x', 'y');
 
document.writeln(
    list[0] === 'x'
    && list[1] === 'y'
    && list[2] === 'ccc'
    && list[3] === 'bb'
);

Question 4

Shows 'true'?
JavaScript
const list = ['a', 'bb', 'ccc', 'dddd'];
const result = list.splice(0, 1);
document.writeln(result);

Question 5

Shows 'true'?
JavaScript
const list = ['a', 'bb', 'ccc', 'dddd'];
const result = list.splice(0, 0);
document.writeln(list.length === 3);

Question 6

Shows 'true'?
JavaScript
const list = ['a', 'bb', 'ccc', 'dddd'];
const result = list.splice(0, 0);
document.writeln(list.length === 4);