Last active
August 29, 2015 14:16
-
-
Save BeauBouchard/4a89cc763cce7527e4ac to your computer and use it in GitHub Desktop.
coding exercise for TripleLift interview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en-US"> | |
<head> | |
<title></title> | |
<!-- META --> | |
<meta charset='UTF-8'> | |
<meta name='author' content='Beau Bouchard'> | |
<meta name='description' content='coding challenge for TripleLift' /> | |
<!-- JS --> | |
<script type="text/javascript" > | |
//Utilizing JavaScript | |
function abbreviate (part, whole) { | |
return (part.length <= 0 ) ? true : !Boolean(~part.split('').map(function (el,i) { return Boolean(~whole.indexOf(el,i)) }).join('\n').indexOf(false)); | |
} | |
var stringOne= "sam"; | |
var stringTwo= "I am sam"; | |
var stringThree= "I am SAM"; | |
var stringFour="I am john"; | |
function stringCompare(strOne, strTwo){ | |
if( ((strTwo.toUpperCase()).indexOf(strOne.toUpperCase())) !== -1){ | |
return console.log(strOne + " is a substring of " + strTwo); | |
} | |
else{ | |
return console.log(strOne + " is not a substring of " + strTwo); | |
} | |
} | |
//Utilizing JavaScript | |
function isIn(part, whole) { | |
var result = true; | |
var booleans = part.map(function(el, i) { | |
return whole.indexOf(el, i) != -1; | |
}); | |
if (booleans.indexOf(false) == -1) { | |
result = false; | |
} | |
return result; | |
} | |
stringCompare(stringOne, stringTwo);//sam is a substring of I am sam | |
stringCompare(stringOne, stringThree);//sam is a substring of I am SAM | |
stringCompare(stringOne, stringFour);//sam is not a substring of I am john | |
</script> | |
</head> | |
<body> | |
<form > | |
<input type="text" name="test" value="No Place Like Home" /> | |
<input type="submit" name="Submit" value="Submit" onClick="add()"/> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment