//odtiaľto kód ignorujte, console.log je preddefinovaná funkcia, ktorá vypíše text alebo číslo na výstup vpravo ->
console = {
log: function (text) {
document.getElementById('console-log').innerHTML += '<p class="console-line">' + text + '</p>';
}
};
//odtiaľto môžete upravovať kód
var hello = 'Vitajte v druhej lekcii programovania v JavaScripte. Dnes si precvičíme podmienky.';
//príklad použitia funkcie console.log
console.log(hello);
//Príklad 1:
//uprav podmienku tak, aby sa vykonal kód v nej
var name = 'Peter';
if (name == '') {
console.log('Your name is ' + name);
}
//Príklad 2
//uprav podmienku tak, aby sa vykonal kód v nej
if (0 === "0") {
console.log('nula je "0"');
}
//Príklad 3
//napíš podmienku, ktorá vypíše pomocou console.log "si dospelý" ak je premenná "age" väčšia, alebo rovná 18. Inak vypíše "si dieťa"
var age = 18;
//Príklad 4
//napíš podmienku, v ktorej priradíš do premennej isLucky true ak má premenná number hodnotu 7, inak bude isLucky false.
var number = 7;
var isLucky;
//Príklad 5
//Napíš podmienku, ktorá vypíše pomocou console.log "Big pig" ak sú obe premenné isBig a isPig true
var isBig = true;
var isPig = true;
//Príklad 6
//Napíš podmienku, ktorá vypíše pomocou console.log "You are big or pig" ak je aspoň jedna premenná isBig a isPig true
var isBig = true;
var isPig = false;
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.