Recap
Overblik
Recap af emner - Skal jeg have et specielt fokus? Skal jeg recappe det hele. Op til jer
Variable
Conditional
Loops
Typer
Number
Strings
Boolean
Array
Objekter
Funktioner
DOM
Fetch
Chart.js
Løse en funktionsopgave
Hvordan går jeg til det?
Flest ord i landenavn
Opgaver
Efter frokost prøveeksamen. Er der nogle der tør
Opgaver
Hvor er dine læringshuller
Start med at gå ginde dine læringshuller med den her GPT jeg har lavet:
https://chatgpt.com/g/g-6911c04d57c8819181c8af41f7b026bf-webteknologi-laeringshuller
Conditional
📝 Even or Odd Emoji — Level 1
Write a function evenOrOdd(n) that returns "✅ even" if n is even, otherwise "❗odd".
📝 First Vowel — Level 2
Create startsWithVowel(str) that returns true if the first character is a vowel (a, e, i, o, u, case-insensitive), else false.
📝 Mini Login Check — Level 2
Write canLogin(user) that returns "Welcome" only if:
A user is active and the users role is a student
Otherwise return "Access denied".
Loops
📝 Sum to N — Level 2
Write sumTo(n) that returns the sum of numbers 1...n.
📝 Count Letter — Level 2
Write countLetter(text, letter) that counts how many times letter appears in text (case-insensitive).
Function 🏋️♀️
📝 Temperature Converter - Level 1
Create a function that takes a string and a number. When called the function should return the character number character responding to the number
📝 Temperature Converter - Level 1
Objective: Write a function convertTemperature(temp, unit) that converts temperatures between Celsius and Fahrenheit. The unit parameter specifies the unit to convert to ('C' for Celsius, 'F' for Fahrenheit).
Alphabeat order - level 2
Create a function that takes two strings. It should return the string that comes first if you sorted it alphabetically
📝 Countries 1 - level 2
Write a function that accepts a list of country names as input and returns the longest country name.
Sample data:
Expected output : "United States of America"
📝 Countries 2 - level 2
Write a function that accepts a list of country names as input and returns the country with the most amount of words in the name.
Sample data :
Expected output : "The United Kingdom of Great Britain and Northern Ireland"
📝 Fruits - level 2
Write a function with two parameters, an array and a letter.
The function returns an array with all the words starting with the letter put in the function argument
📝 CPR - level 3
Write a function that receives an array of cpr numbers.
The function will filter all cpr numbers that do not follow the following rules of a cpr number:
It should be 11 characters long
The first 2 indices cannot be higher than 31
The next 2 indicies cannot be higher than 12
The next character should be a "-"
📝 Names - level 2
Write a function that filters all names above the length of 5 letters.
The function should use the filter syntax
Objects
Event Scheduler - level 3
Objective: Write a function scheduleEvents(events, start) that takes an array of event objects (each with a name and duration in minutes) and a start time. The function should return a schedule mapping each event to its start time.
Example
DOM
📝 Button clicker - level 1
Add a button to an html page. When clicked it should change the background color of the website
📝 Live Character Counter — Level 2
Objective: Show how many characters the user has typed.
HTML:
<input id="msg">and<span id="count">0</span>JS: on
inputupdate#count.
Expected: Typing “hello” shows 5.
📝 Add Items to a List — Level 3
Objective: User types a word and clicks “Add” → it appears as a new <li>.
HTML:
<input id="item"> <button id="add">Add</button> <ul id="list"></ul>JS: On click, create
li, settextContent, append to#list. Ignore empty strings.
Bonus: Clear the input after adding.
Fetch
📝 Random Dog Image — Level 2
Objective: Create a website with a button. When clicked it should fetch a random dog image and display it in an <img>. Here is the api: https://dog.ceo/api/breeds/image/random
Problem solving
Path Finder - master level 🧙
Objective: Write a function findPath(maze, start, end) that determines a path through a maze.
Description:
The Maze: The maze is represented as a 2D array where each element can either be
0or1. A0represents an open space where one can move, and a1represents a wall which cannot be traversed.Start and End Points: The
startandendparameters are coordinates in the maze, given as an array of two numbers,[rowIndex, columnIndex]. Your function should find a path from the start coordinate to the end coordinate.Moving Through the Maze: You can move up, down, left, or right, but cannot move diagonally. Also, you cannot go outside the bounds of the maze.
Return Value: The function should return an array of strings, each string being a move:
'up','down','left', or'right'. This array should represent the sequence of moves that leads from the start to the end point. If no path is possible, the function can return an indication of this, likenullor an empty array.
Example:
Suppose we have the following maze:
And we call the function with:
Here, [0, 0] is the top-left corner (starting point) and [4, 4] is the bottom-right corner (ending point).
Expected Output:
The function should return an array of moves that will take you from [0, 0] to [4, 4], navigating through open spaces (0) and avoiding walls (1). For example, one possible solution could be:
This sequence would navigate the maze from the start to the end as specified.
Last updated