Skip to content

Instantly share code, notes, and snippets.

@jaf7
Created August 10, 2018 18:30
Show Gist options
  • Save jaf7/22b3b40f8c86338d82fb095dbc4a7c61 to your computer and use it in GitHub Desktop.
Save jaf7/22b3b40f8c86338d82fb095dbc4a7c61 to your computer and use it in GitHub Desktop.
Bluecore Coding Assessment
// Question 1
function incorrectChars( input, output) {
const inputString = input.toLowerCase();
const outputString = output.toLowerCase();
const multiple = outputString.length / inputString.length;
let incorrect = 0;
for ( let i = 0; i < outputString.length - inputString.length; i + inputString.length ) {
const outputSubString = outputString.substring(i, i+inputString.length);
console.log('outputSubString: ' + outputSubString)
if ( outputSubString !== inputString ) {
incorrect ++;
}
}
return incorrect;
}
// Question 2
function hasPalindrome( str ) {
const allPermutations = str + str
for ( let i = 0; i < allPermutations.length - str.length; i++) {
console.log('');
}
function areAnagrams(stringA, stringB) {
return sorted(stringA) === sorted(stringB);
}
function sorted(str) {
let cleaned = str.replace(/ /g, '')
.toLowerCase()
.split('')
.sort()
.join();
return cleaned;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment