Last active
September 23, 2015 06:49
-
-
Save rserna2010/69a086a55d180bfa6382 to your computer and use it in GitHub Desktop.
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
decryptC = function (stringParam) { | |
console.log("NEW TEST------------------------------------") | |
console.log("THIS IS FOR STRING: " + stringParam ) | |
var wordArray = stringParam.split(" ") | |
results = []; | |
var skip_index = "" | |
for(var i = 0; i<wordArray.length; i++){ | |
var word = wordArray[i] | |
var n = i | |
if (i == 0) { | |
results.push(word[0]) | |
} else if (i == skip_index){ | |
console.log("skip word: " + word) | |
} | |
else { | |
// lengthOfWord = word.length | |
var letter = word[n] // this is Nth letter of the word | |
if (letter == undefined) { | |
var nextWord = wordArray[i+1] | |
var indexOfNextWord = n - word.length | |
letter = nextWord[indexOfNextWord] | |
results.push(letter) | |
skip_index = i + 1 | |
} else { | |
results.push(letter) | |
} | |
} | |
} | |
var answer = results.join("") | |
console.log(answer) | |
return answer | |
} | |
// console.log(decryptC ("a ob ooc dd oeoo ooooof") == "abcef") | |
// console.log(decryptC ("a b c") == "ac") | |
// console.log(decryptC ("oh i understand banter") == "out") | |
console.log(decryptC ("a b c d e f g") == "acg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment