Skip to content

Instantly share code, notes, and snippets.

@faddah
Created August 1, 2020 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faddah/009b99a839bf0be25212b1738a14f472 to your computer and use it in GitHub Desktop.
Save faddah/009b99a839bf0be25212b1738a14f472 to your computer and use it in GitHub Desktop.
String Compare Coding Challenge question
function missingWords(s, t) {
// split each string into an Array and have a result Array
const sArr = s.split(" ");
const tArr = t.split(" ");
let missingResult = [];
// compare the strings using a loop, pushing missing words into final missingResult Array
for (let i = 0; i < sArr.length; i++) {
if (!tArr.find(el => el === sArr[i])) {
missingResult.push(sArr[i]);
}
}
// display the final missingResult
// console.log(missingResult);
return missingResult;
}
let a = "The programming language of Python is one of the most widely used and useful out there today for Web and Server apps as well as large data analysis";
let b = "The language of is the most and there for apps as well";
missingWords(a, b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment