Created
May 27, 2022 11:03
-
-
Save thedom85/45c182e6000355c5d519d71217cf1277 to your computer and use it in GitHub Desktop.
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
// https://www.codewars.com/kata/51c8e37cee245da6b40000bd/train/javascript | |
function solution(input, markers) { | |
let outcome = []; | |
let inputs = input.split("\n"); | |
for (let k = 0; k < inputs.length; k++) { | |
for (const m of markers) { | |
if(inputs[k].indexOf(m)>-1){ | |
inputs[k] = inputs[k].substring(0, inputs[k].indexOf(m)); | |
} | |
} | |
if(inputs[k].trim().length) | |
outcome.push(inputs[k].trim()); | |
} | |
return outcome.join("\n"); | |
}; | |
//console.log(solution("aaa!bbb", ["!"]), "--aaa") | |
//console.log(solution("aaa!bbb\nccc", ["!"]), "--aaa ccc") | |
//console.log("apples, plums % and bananas pears oranges !applesauce", ["%", "!"], "apples, plums pears oranges") | |
// console.log("Q @b\nu\ne -e f g", ["@", "-"], "Q\nu\ne") | |
//console.log("apples, plums % and bananas\npears\noranges !applesauce", ["%", "!"], "apples, plums\npears\noranges") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment