User Story

AS A <role>
I WANT <feature>
SO THAT <benefit>

The Problem

  • a challenge that the user has

The Need

  • the need that the user would like met

The Ask

  • the specific thing that would meet the need

Acceptance Criteria

label

GIVEN <precondition>
WHEN <action>
THEN <outcome>
0 of 0 of 0

Test Cases

Input

Output

Implementation

Performance

Problems

JavaScript CheatSheet

Declare a local variable
var name; // declare but do not initialize
var name = value; // declare and initialize
let name [= value]; // block-scoped variable declaration
const name = value; // block-scoped constant
// Note: const can't be reassigned or redeclared
Declare an empty array
var a = [];
Push elements onto the array
a.push( value )
Access a particular element in the array
a[i]
Sort the array in default (string) order
a.sort() // Only applies to arrays, not strings
Iterate over the elements in the array
for ( i in a ) { v = a[i]; ... }
Make a copy of an array
var b = a.slice()
Declare an empty object / hash-map
var h = {};
Add a new key/value pair
h.key = "value" or h["key"] = "value"
Access the value stored for a particluar key
h.key or h["key"]
Test if the key exists already
h.hasOwnProperty( "key" )
Iterate over the keys
for ( k in h ) { v = h[k]; ... }
Compare arrays or hash/objects
Javascript provides no built-in mechanism for deep comparison, you must roll-your-own
Get the length of a string
var s = "foo"; s.length == 3
Access the nth character in a string
var s = "foo";
s[0] == "f"; // faster, but doesn't work on IE7
s.charAt(0) == "f"; // slower, but universally supported
Find the first instance of character/substring
var s = "foo";
s.indexOf('o') == 1; // 0-based indexing
s.indexOf('x') == -1; // -1 for not found
Replace all instances of character X with character Y
s.replace(/X/g, 'Y' )
Convert a string to an array of characters
var s = "foo";
// intent: a = [ 'f', 'o', 'o' ]
var a = [...s]; // option 1 - spread operator
var a = s.split(''); // option 2 - split function
Concatenate the elements of an array into a string
var s = a.join('');
Increment/decrement a variable
x += 1 or x -= 1
Get or test the type of a variable
typeof "foo" === "string" and
typeof 42 === "number" and
typeof {foo:"bar"} === "object" and
typeof [1,2,3] === "object"