Skip to content

Instantly share code, notes, and snippets.

@vlazar-
Created January 24, 2023 11:48
Show Gist options
  • Save vlazar-/12399ef66aaf44d1c1d822d5c5ada6b6 to your computer and use it in GitHub Desktop.
Save vlazar-/12399ef66aaf44d1c1d822d5c5ada6b6 to your computer and use it in GitHub Desktop.
JavaScript - prijestupna godina
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prijestupna Godina</title>
</head>
<body>
<script>
function isLeap(year) {
if (year % 4 === 0) {
if (year % 100 === 0) {
if (year % 400 === 0) {
return true;
} else {
return false;
}
} else {
return true;
}
} else {
return false;
}
}
let year = prompt('Unesi godinu:');
alert(isLeap(year));
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prijestupna Godina</title>
</head>
<body>
<script>
function isLeap(year) {
if ((0 == year % 4) && (0 != year % 100) || (0 == year % 400)) {
return true;
} else {
return false;
}
}
let year = prompt('Unesi godinu:');
alert(isLeap(year));
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prijestupna Godina</title>
</head>
<body>
<script>
function isLeap(year) {
let result = false;
if ((0 == year % 4) && (0 != year % 100) || (0 == year % 400)) {
result = true;
}
return result;
}
let year = prompt('Unesi godinu:');
alert(isLeap(year));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment