Skip to content

Instantly share code, notes, and snippets.

@slopeofhope81
Created January 24, 2014 19:31
Show Gist options
  • Save slopeofhope81/8604352 to your computer and use it in GitHub Desktop.
Save slopeofhope81/8604352 to your computer and use it in GitHub Desktop.
/*4.4)Write a function called startsWith that takes two arguments, both strings. It returns true when the first argument starts with the characters in the second argument, and false otherwise. */
function startsWith(a, b) {
if (b.slice(0, a.length) == a) return true;
else return false;
}
a="steve"
b="steve is coding hard"
document.write(startsWith(a,b));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment