Remove Last Element From String Javascript Program