Created
April 19, 2017 10:46
-
-
Save abdu95/b008ea6820315c8145d6585b737468ef to your computer and use it in GitHub Desktop.
// source http://jsbin.com/vecuxav
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<p id="demo"></p> | |
<script id="jsbin-javascript"> | |
var text = ""; | |
for (var year = 2014; year <= 2050; year++) | |
{ | |
var d = new Date(year, 0, 1); | |
if ( d.getDay() === 0 ) | |
text+= "1st January is being a Sunday "+year+ "<br>"; | |
} | |
document.write(text); | |
/* where the program takes a random integer | |
between 1 to 10, the user is then prompted to input a guess | |
number. If the user input matches with guess number, | |
the program will display a message "Good Work" | |
otherwise display a message "Not matched".*/ | |
/* where the program takes a random integer | |
between 1 to 10, the user is then prompted to input a guess | |
number. If the user input matches with guess number, | |
the program will display a message "Good Work" | |
otherwise display a message "Not matched".*/ | |
//userNumber = window.prompt("Input a Number : "); | |
compNumber = Math.floor(Math.random()*10)+1; | |
if (userNumber == compNumber){ | |
alert("Good Work"); | |
} else { | |
alert("Not matched, actually it was " + compNumber); | |
} | |
//8. calculate days left until next Christmas. | |
today=new Date(); | |
var cmas=new Date(today.getFullYear(), 11, 25); | |
if (today.getMonth()==11 && today.getDate()>25) | |
{ | |
cmas.setFullYear(cmas.getFullYear()+1); | |
} | |
var one_day=1000*60*60*24; | |
document.write(Math.ceil((cmas.getTime()-today.getTime())/(one_day))+ | |
" days left until Christmas!"); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
var text = ""; | |
for (var year = 2014; year <= 2050; year++) | |
{ | |
var d = new Date(year, 0, 1); | |
if ( d.getDay() === 0 ) | |
text+= "1st January is being a Sunday "+year+ "<br>"; | |
} | |
document.write(text); | |
/* where the program takes a random integer | |
between 1 to 10, the user is then prompted to input a guess | |
number. If the user input matches with guess number, | |
the program will display a message "Good Work" | |
otherwise display a message "Not matched".*/ | |
/* where the program takes a random integer | |
between 1 to 10, the user is then prompted to input a guess | |
number. If the user input matches with guess number, | |
the program will display a message "Good Work" | |
otherwise display a message "Not matched".*/ | |
//userNumber = window.prompt("Input a Number : "); | |
compNumber = Math.floor(Math.random()*10)+1; | |
if (userNumber == compNumber){ | |
alert("Good Work"); | |
} else { | |
alert("Not matched, actually it was " + compNumber); | |
} | |
//8. calculate days left until next Christmas. | |
today=new Date(); | |
var cmas=new Date(today.getFullYear(), 11, 25); | |
if (today.getMonth()==11 && today.getDate()>25) | |
{ | |
cmas.setFullYear(cmas.getFullYear()+1); | |
} | |
var one_day=1000*60*60*24; | |
document.write(Math.ceil((cmas.getTime()-today.getTime())/(one_day))+ | |
" days left until Christmas!"); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = ""; | |
for (var year = 2014; year <= 2050; year++) | |
{ | |
var d = new Date(year, 0, 1); | |
if ( d.getDay() === 0 ) | |
text+= "1st January is being a Sunday "+year+ "<br>"; | |
} | |
document.write(text); | |
/* where the program takes a random integer | |
between 1 to 10, the user is then prompted to input a guess | |
number. If the user input matches with guess number, | |
the program will display a message "Good Work" | |
otherwise display a message "Not matched".*/ | |
/* where the program takes a random integer | |
between 1 to 10, the user is then prompted to input a guess | |
number. If the user input matches with guess number, | |
the program will display a message "Good Work" | |
otherwise display a message "Not matched".*/ | |
//userNumber = window.prompt("Input a Number : "); | |
compNumber = Math.floor(Math.random()*10)+1; | |
if (userNumber == compNumber){ | |
alert("Good Work"); | |
} else { | |
alert("Not matched, actually it was " + compNumber); | |
} | |
//8. calculate days left until next Christmas. | |
today=new Date(); | |
var cmas=new Date(today.getFullYear(), 11, 25); | |
if (today.getMonth()==11 && today.getDate()>25) | |
{ | |
cmas.setFullYear(cmas.getFullYear()+1); | |
} | |
var one_day=1000*60*60*24; | |
document.write(Math.ceil((cmas.getTime()-today.getTime())/(one_day))+ | |
" days left until Christmas!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment