Skip to content

71-simplify-path

DevGod
DevGod
Elf Vtuber
/**
* @param {string} path
* @return {string}
*/
var simplifyPath = function(path) {
let blah = path.split("/");
let stack = [];
for(let b of blah){
if(b == ".."){
stack.pop();
}else if(b !== '' && b !== '.'){
stack.push(b);
}
}
return "/"+stack.join('/');
};