The output in console is same as in question but it is still not meeting the requirement