From 7bd673b93558171d58bc3ccb0b8bc09428212345 Mon Sep 17 00:00:00 2001 From: Aadil <77232799+aadil42@users.noreply.github.com> Date: Mon, 3 Jul 2023 17:24:41 +0530 Subject: [PATCH] Update 0071-simplify-path.js Removed unnecessary nested if statment --- javascript/0071-simplify-path.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/javascript/0071-simplify-path.js b/javascript/0071-simplify-path.js index 7bc9b6ca0..8a4faa3c3 100644 --- a/javascript/0071-simplify-path.js +++ b/javascript/0071-simplify-path.js @@ -12,12 +12,9 @@ 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); } @@ -25,6 +22,7 @@ var simplifyPath = function(path) { } else { currunt += path[i]; } + } myStack = myStack.join('/');