AP CSP Review Day! PDF

Summary

This document provides review material on lists, loops, and traversals, geared towards an introductory level computer science course. It outlines the definitions and examples of these computer science concepts.

Full Transcript

Lists Rules: - Definition: A list is a collection of elements stored together. - Declare a variable with var - Use square brackets at the start and end of the list - Separate items with a comma - Use quotation marks for strings - To find the first element in the list: console...

Lists Rules: - Definition: A list is a collection of elements stored together. - Declare a variable with var - Use square brackets at the start and end of the list - Separate items with a comma - Use quotation marks for strings - To find the first element in the list: console.log(list name) - To find the last element in a list: console.log(list name[list name.length-1]) - Index → position in the list - insertItem → (list, index, element)→ adds an item anywhere in the list - appendItem→ (list, element) → adds an item at the end of the list - removeItem → (list, index)→ removes any item in the list Loops: - i++ → adds 1 each time until the condition is false - i- - → subtracted 1 each time until the condition is false Traversals: - < → less than sign → represents the minimum - > → greater than sign → represents the maximum - y/list.length → represents the average - y → is the sum of all the elements added together - + → addition symbol → represents addition

Use Quizgecko on...
Browser
Browser