0
var userbirth = prompt("Enter You Birthday. Please Enter in this format DDMMYYYY");
var bdate = userbirth.substring(0,2);
var bmonth = userbirth.substring(2,4);
var byear = userbirth.substring(4,8);
console.log(bdate);

function check2(){
 console.log(byear);
}
window.onload = check2();

In the first case when it is a outside function the code is executed correctly. But when it is inside a function it shows undefined.
Why is that like so? Can anybody help me with it.
Thanks in advance:)

Code Maniac
  • 35,187
  • 4
  • 31
  • 54
adhith
  • 1

0 Answers0