Created
August 1, 2020 18:12
-
-
Save faddah/009b99a839bf0be25212b1738a14f472 to your computer and use it in GitHub Desktop.
String Compare Coding Challenge question
This file contains hidden or 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 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