Comp 110 Cheat Sheet

Programming Environment

These commands are run from the integrated terminal in VSCode. To open the integrated terminal, press Ctrl+` (backtick/tilde button) or go to the View menu and select Integrated Terminal.

Download Latest Code:

npm run pull

Start the Programming Environment:

npm start

Stop the Programming Environment:

Press Ctrl+C in the integrated terminal or click the Close button in your web browser's programming environment view.

TypeScript Language Constructs

Primitive types.

boolean, number, string

Declare a variable.

let <name>: <type> = <value>;

Declare an array.

let <name>: <type>[] = [];

Test Equality

<value> === <value>

Declare a function.

function <name>(<parameter name>: <type>...): <return type> {
}

IntroCS Standard Library Functions

print

function print(value: any): void;

value - Print a string representation of any argument to the browser.

image

function image(url: string): void;

url - The web address of an image, like a gif, that you would like to display in the app.

clear

function clear(): void;

Clears any previous output on the screen.

promptString

function promptString(text: string, callback: function): void;

text - The instruction text to prompt the user with.

callback - A function that has a single string parameter. This function will be called once the user has input a string into the prompt.

promptNumber

function promptNumber(text: string, callback: function): void;

text - The instruction text to prompt the user with.

callback - A function that has a single number parameter. This function will be called once the user has input a number into the prompt.

promptBoolean

function promptBoolean(text: string, callback: function): void;

text - The instruction text to prompt the user with.

callback - A function that has a single number parameter. This function will be called once the user has input a number into the prompt.