Skip to content

Instantly share code, notes, and snippets.

View sashak007's full-sized avatar
🐝

Natasha sashak007

🐝
View GitHub Profile
/**
QUESTION
given an array of strings, determine if the strings can be rearranged
to form a palindrome.
**/
function possiblePalidrome(arr) {
var totalLetters = arr.reduce((total, set) => {
total += set.length;
return total;
function flatten(input) {
let flattenArr = [];
for(let i = input.child.length - 1; i >= 0; i--) {
for(const prop in input.child[i]) {
if(prop === 'child') {
flattenArr = flattenArr.concat(flatten(input.child[i]));
delete input.child[i].child;
flattenArr.push(input.child[i]);
return flattenArr;
}
// create a method that determines a winner from a given board. Manipulting matrix datasets.
var board = [
['x','x', 'o'],
['x', 'o', 'x'],
['x',null, null],
];
var board2 = [
['o', null, 'o'],
@sashak007
sashak007 / recursion-practice.markdown
Last active May 16, 2017 00:43
Recursion Practice
// Correct Way
function indexOf(str, query) {
for(var i = 0; i < str.length; i++) {
for(var q = 0; q < query.length; q++) {
if (str[i+q] !== query[q]) {
break;
}
if (q === query.length - 1) {
return i;
}