Last active
October 17, 2015 23:05
-
-
Save keronsen/11370238 to your computer and use it in GitHub Desktop.
JavaScript-oppgaver
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> | |
<title>Oppgave 1</title> | |
<link rel="stylesheet" href="http://finncdn.no/bb/latest/css/so/so.min.css" /> | |
</head> | |
<body class="mal"> | |
<h1>Oppgave 1</h1> | |
<p>Skriv kode slik at knappen under endrer tekst til "Thank You!" når du klikker på den. Du skal ikke bruke jQuery eller andre biblioteker.</p> | |
<button id="MyButton" class="r-margin">Hit me!</button> | |
<script> | |
// skriv ditt script her | |
</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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Oppgave 2</title> | |
<link rel="stylesheet" href="http://finncdn.no/bb/latest/css/so/so.min.css" /> | |
</head> | |
<body class="mal"> | |
<h1>Oppgave 2</h1> | |
<p>Koden under lager et Person-objekt med et firstName og lastName, og bruker getFullName() til å skrive ut en hilsen, men constructoren er ikke ferdig. Gjør denne ferdig slik at teksten som skrives ut blir riktig ("Hello, Ola Nordmann")</p> | |
<div id="Output" class="r-margin pam bg-white inlineblockify"></div> | |
<script> | |
function Person() { | |
} | |
Person.prototype.getFullName = function() { | |
return this.firstName + " " + this.lastName; | |
} | |
var person = new Person("Ola", "Nordmann") | |
var output = document.getElementById("Output"); | |
output.innerHTML = "Hello, " + person.getFullName(); | |
</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
// OPPGAVE 3 | |
// | |
// Gitt at det finnes en funksjon println(n) som skriver ut tallet n, | |
// hva skrives ut fra koden under, og fra hvilke kodelinjer? | |
// NB: Det er juks å kjøre koden! ;) | |
var a = 1001; | |
var b = 1002; | |
println(1003); | |
(function(a) { | |
println(a); | |
println(b); | |
[1004,1005].forEach(function(b) { | |
println(b); | |
}); | |
for(var b = 1006; b <= 1007; b++) { | |
println(b); | |
} | |
println(b); | |
})(1008); | |
println(1009); |
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> | |
<title>Oppgave 4</title> | |
<link rel="stylesheet" href="http://finncdn.no/bb/latest/css/so/so.min.css" /> | |
</head> | |
<body class="mal"> | |
<h1>Oppgave 4</h1> | |
<p class="mbl">Skriv kode slik at du kan trykke på tabelloverskriftene for å sortere tabellen. <br>Du skal ikke bruke jQuery eller andre biblioteker.</p> | |
<script> | |
// skriv ditt script her | |
</script> | |
<table id="MyTable" class="r-margin condensed bg-white"> | |
<thead> | |
<tr class="clickable"> | |
<th>Fornavn</th> | |
<th>Etternavn</th> | |
<th>Brukernavn</th> | |
<th>Adresse</th> | |
<th>Poststed</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>Bente</td> | |
<td>Ulvestad</td> | |
<td>fibeulve</td> | |
<td>Jens Bjelkes gate 78a</td> | |
<td>0652 Oslo</td> | |
</tr> | |
<tr> | |
<td>Anders Olsen</td> | |
<td>Sandvik</td> | |
<td>andsandv</td> | |
<td>Sannergata 30C</td> | |
<td>0557 Oslo</td> | |
</tr> | |
<tr> | |
<td>Lotte</td> | |
<td>Johansen</td> | |
<td>filojoha</td> | |
<td>Hauketoåsen 16</td> | |
<td>1266 Oslo</td> | |
</tr> | |
<tr> | |
<td>Henning</td> | |
<td>Gjetanger</td> | |
<td>fihegjet</td> | |
<td>Slottsplassen 5</td> | |
<td>0010 Oslo</td> | |
</tr> | |
<tr> | |
<td>Roar</td> | |
<td>Johansen</td> | |
<td>firojoha</td> | |
<td>Glimmerveien 7</td> | |
<td>3518 Hønefoss</td> | |
</tr> | |
<tr> | |
<td>Yvonne</td> | |
<td>Svae-Grotli</td> | |
<td>fiyvsvae</td> | |
<td>Holmåsveien 6</td> | |
<td>1440 Drøbak</td> | |
</tr> | |
<tr> | |
<td>Tommy</td> | |
<td>Johansen</td> | |
<td>tomjohan</td> | |
<td>Høymyrfjellet 19</td> | |
<td>1389 Heggedal</td> | |
</tr> | |
<tr> | |
<td>Karl-Erik</td> | |
<td>Rønsen</td> | |
<td>karronse</td> | |
<td>Slengåsen 21</td> | |
<td>2020 Skedsmokorset</td> | |
</tr> | |
</tbody> | |
</table> | |
</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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Oppgave 5</title> | |
<link rel="stylesheet" href="http://finncdn.no/bb/latest/css/so/so.min.css" /> | |
</head> | |
<body class="mal"> | |
<h1>Oppgave 5</h1> | |
<p>Fullfør funksjonen createSequence() slik at den returnerer en funksjon som gir ett og ett heltall hver gang den kalles. Første gang den kalles får du 1, neste gang 2, så 3, osv... Når din implementasjon er riktig vil resten av koden på siden sørge for å skrive ut alle positive heltall, ti tall per sekund.</p> | |
<div id="Output" class="r-margin bg-white pam">The sequence:</div> | |
<script> | |
function createSequence() { | |
// Din implementasjon her... | |
} | |
var sequence = createSequence(); | |
var output = document.getElementById("Output"); | |
setInterval(function() { | |
output.innerHTML += " " + sequence(); | |
}, 100); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment