A Pen by Dano Manion on CodePen.
Created
December 22, 2019 13:36
-
-
Save danomanion/b4235454c8cdeee2a5092f22287b1e0f to your computer and use it in GitHub Desktop.
Practice
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
// Clear Console | |
console.clear() | |
const myFunct = function (s1, s2) { | |
s1 = s1.split("") | |
s2 = s2.split("") | |
let s3 = "" | |
for (let i = 0; i < s1.length; i++) { | |
// console.log(s1[i]) | |
// console.log(s2[0]) | |
if (s1[i] == s2[0]) { | |
s3 += s1[i] | |
s2.shift() | |
} else { | |
s2.shift() | |
} | |
} | |
console.log(s3) | |
} | |
// Log | |
// console.log(myFunct("ABAZDC", "BACBAD")) | |
myFunct("ABAZDC", "BACBAD") // ABAD | |
// My Tests | |
// console.assert(myFunct("ABAZDC", "BACBAD") == "ABAD", '"ABAZDC", "BACBAD" is not ABAD') | |
// console.assert(myFunct("AGGTAB", "GXTXAYB") == "GTAB", '"AGGTAB", "GXTXAYB" is not GTAB') | |
// console.assert(myFunct("aaaa", "aa") == "aa", '"aaaaa", "aa" is not aa') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment