Question 3
OCR Computer Science June 2017 Paper 1AS6 marks
On the specification
- (a)
- 2.2 Problem solving and programming
- (b)
- 1.4 Data types, data structures and algorithms
Question text
3 The following JavaScript has been found to crash certain web browsers. Line Code 1 var total = ""; 2 for(var j = 0; j < 200000; j++) 3 { 4 total = total + j.toString(); 5 history.pushState(0,0, total); 6 } j.toString() converts j to a string. It is the JavaScript equivalent to str(j). (a) Complete the table below. Line Effect of Code 1 [2] 2 [1] 3 4 [1] 5 Pushes total onto a stack that holds the browser’s history. 6 (b) Line 5 pushes total onto a stack. Define the term stack, stating why it is suited to holding a web browser’s history. [2]