This file contains 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
function makeBoard(n) { | |
var board = [] | |
for (var i = 0; i < n; i++) { | |
board.push([]) | |
for (var j = 0; j < n; j++) { | |
board[i].push(false) | |
} | |
} | |
board.togglePiece = function(i, j) { | |
this[i][j] = !this[i][j] |
This file contains 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
function isBalanced (string) { | |
var queue = []; | |
for(var i = 0; i < string.length; i++){ | |
if(string[i] === "("){ | |
queue.push(string[i]); | |
} | |
if(string[i] === ")"){ | |
queue.pop(); | |
} | |
} |
This file contains 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
var reverseList = function(list){ | |
var tempHead = list.head; | |
var tempTail = list.tail; | |
var prevNode = list.head | |
var currentNode = this.head.next; | |
while(currentNode) { | |
var holder = currentNode.next; | |
currentNode.next = prevNode; | |
prevNode = currentNode; | |
currentNode = holder |
This file contains 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
var BinarySearchTree = function(value){ | |
var instance = Object.create(binaryTreeMethods); | |
instance.value = value | |
instance.left = null; | |
instance.right = null; | |
return instance; |
This file contains 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
function findLongestWord(str) { | |
str = str.split(' '); | |
return str.reduce(function(a,b ){ return a.length > b.length ? a : b;}).length | |
} | |
findLongestWord("The quick brown fox jumped over the lazy dog"); |
This file contains 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
function end(str, target) { | |
return str.substring(str.length - target.length) === target; | |
} | |
end("Bastian", "n"); |
This file contains 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
function truncate(str, num) { | |
// Clear out that junk in your trunk | |
return num >= str.length? str: str.slice(0, num - (num <= 3 ? 0 : 3)) + '...'; | |
} | |
truncate("A-tisket a-tasket A green and yellow basket", 11); |
This file contains 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
function chunk(arr, size) { | |
var results = []; | |
while(arr.length){ | |
results.push(arr.splice(0,size)); | |
} | |
return results; | |
} | |
chunk(["a", "b", "c", "d"], 2); |
This file contains 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
$.ajax({ | |
url: 'MASHAPE-URL', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile | |
type: 'POST', // The HTTP Method | |
data: {}, // Additional parameters here | |
dataType: 'json', | |
success: function(data) { alert(JSON.stringify(data)); }, | |
error: function(err) { alert(err); }, | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader("X-Mashape-Authorization", "YOUR-MASHAPE-KEY"); // Enter here your Mashape key | |
} |
This file contains 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"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Datanyze Challenge</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> | |
<style> |