Skip to content

Instantly share code, notes, and snippets.

@danomanion
Last active December 22, 2019 14:31
Show Gist options
  • Save danomanion/c9153da8601388b1ee5b194f3534e6f0 to your computer and use it in GitHub Desktop.
Save danomanion/c9153da8601388b1ee5b194f3534e6f0 to your computer and use it in GitHub Desktop.
Practice
// Clear Console
console.clear()
const myFunct = function (s1, s2) {
let result = ""
if (s1 >= s2) {
var longest = s1.split("")
} else {
var shortest = s2.split("")
}
// for (let i = 0; i < longest.length; i++) { // B
// for (let j = 0; j < shortest.length; j++) { // A
// if (shortest[j] == longest[i]) {
// result = shortest[j]
// }
// }
// }
console.log(result)
}
// 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