Update tab.js

Fixed the nested if else block