Skip to content

Commit 7bd673b

Browse files
authored
Update 0071-simplify-path.js
Removed unnecessary nested if statment
1 parent ffc213f commit 7bd673b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Diff for: javascript/0071-simplify-path.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ var simplifyPath = function(path) {
1212
path = `/${path}/`;
1313
for(let i = 0; i < path.length; i++) {
1414

15-
console.log(myStack);
1615
if(path[i] === '/') {
1716
if(currunt == '..') {
18-
if(myStack.length) {
19-
myStack.pop();
20-
}
17+
myStack.pop();
2118
} else if(currunt !== '' && currunt !== '.') {
2219
myStack.push(currunt);
2320
}
2421
currunt = '';
2522
} else {
2623
currunt += path[i];
2724
}
25+
2826
}
2927

3028
myStack = myStack.join('/');

0 commit comments

Comments
 (0)