Skip to content

Commit

Permalink
Update 0071-simplify-path.js
Browse files Browse the repository at this point in the history
Removed unnecessary nested if statment
  • Loading branch information
aadil42 authored Jul 3, 2023
1 parent ffc213f commit 7bd673b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions javascript/0071-simplify-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ var simplifyPath = function(path) {
path = `/${path}/`;
for(let i = 0; i < path.length; i++) {

console.log(myStack);
if(path[i] === '/') {
if(currunt == '..') {
if(myStack.length) {
myStack.pop();
}
myStack.pop();
} else if(currunt !== '' && currunt !== '.') {
myStack.push(currunt);
}
currunt = '';
} else {
currunt += path[i];
}

}

myStack = myStack.join('/');
Expand Down

0 comments on commit 7bd673b

Please sign in to comment.