diff --git a/Codealong/controller.js b/Codealong/controller.js
index 8b13789..daa569a 100644
--- a/Codealong/controller.js
+++ b/Codealong/controller.js
@@ -1 +1,34 @@
+function addBike() {
+ let newBike = model.input.newBike;
+ let myBike = {
+ id: addNewId(),
+ brand: newBike.brand,
+ gears: newBike.gears,
+ state: newBike.state,
+ isAvilable: newBike.isAvilable,
+ description: newBike.description,
+ };
+ model.data.bikes.push(myBike);
+ newBike.id = "";
+ newBike.brand = "";
+ newBike.gears = "";
+ newBike.state = "";
+ newBike.description = "";
+ console.log(model.data.bikes)
+ updateView();
+ }
+
+function addNewId(){
+ let newId = Math.floor(Math.random()*9999)
+ for(let i = 0; i < model.data.bikes.length; i++){
+
+ if(newId === model.data.bikes[i].id){
+ addNewId();
+ }
+
+
+ }
+ return newId;
+ }
+
\ No newline at end of file
diff --git a/Codealong/modell.js b/Codealong/modell.js
deleted file mode 100644
index d7d85c7..0000000
--- a/Codealong/modell.js
+++ /dev/null
@@ -1,36 +0,0 @@
-// Sykkelutleie
-// Kunden ønsker en applikasjon som skal kunne liste opp syklene den har så andre kan leie dem. Det skal også være mulig å legge til nye sykler etterhvert.
-// Lag en modell som kan fungere til teksten ovenfor
-// Lag viewfunksjon for å vise frem alle syklene våre
-// Lag en controllerfunksjon og et view til for å kunne legge til nye sykler
-const app = document.getElementById('app');
-
-const modell = {
- app: {
-
- },
- input: {
-
- },
- data: {
- bikes: [
- {
- id: 1,
- modell: 'DBS',
- gears: 5,
- description: '',
- state: 'works',
- isAvilable: true,
-
- },
- {
- id: 2,
- modell: 'DBS',
- gears: 7,
- description: '',
- state: 'refurbished',
- isAvilable: true,
- },
- ]
- },
-}
\ No newline at end of file
diff --git a/Codealong/sykkel.html b/Codealong/sykkel.html
index 8c0f796..0ce0036 100644
--- a/Codealong/sykkel.html
+++ b/Codealong/sykkel.html
@@ -3,11 +3,16 @@
- Document
+ Sykkelutleie
+
-
+
+
+
+
+
diff --git a/Codealong/view.js b/Codealong/view.js
index cb3cd1b..81a2d1a 100644
--- a/Codealong/view.js
+++ b/Codealong/view.js
@@ -1,31 +1,53 @@
updateView();
function updateView() {
- app.innerHTML = /*html*/ `
- Bikes R Us
+ header.innerHTML = '';
+ main.innerHTML = /*html*/ `
Alle sykkler:
- ${bikeList()}
-
+ ${bikeList()}`;
+ input.innerHTML = /*html*/ `
+ Legg til en sykkel:
+ ${addBikeview()}
`;
}
+
function bikeList() {
let bikeHtml = '';
-
- for (i = 0; i < modell.data.bikes.length; i++) {
+ let bikes = model.data.bikes
+ for (i = 0; i < model.data.bikes.length; i++) {
bikeHtml += /*html*/ `
-
+
- Merke: ${modell.data.bikes[i].modell}
- Gir: ${modell.data.bikes[i].gears}
- Beskrivelse: ${modell.data.bikes[i].description}
- Tilgjengelig: ${modell.data.bikes[i].isAvilable}
- Tilstand: ${modell.data.bikes[i].state}
- `;
+
Merke: ${bikes[i].brand}
+
Gir: ${bikes[i].gears}
+
Beskrivelse: ${bikes[i].description}
+
Tilgjengelig: ${bikes[i].isAvilable}
+
Tilstand: ${bikes[i].state}
+
+
`;
}
return bikeHtml;
}
-function addBikeview(){
+function addBikeview() {
let addBikeHtml = /*html*/ `
-
+
+ Merke:
+
+
+
+ Gir:
+
+
+
+ Er sykkelen tigjengelig Ja
+ Nei
+
+
+ Beskrivelse:
+
+
+
+ Legg til sykkel
`;
+ return addBikeHtml
}
\ No newline at end of file
diff --git a/oppgaver/checkLetters.js b/oppgaver/checkLetters.js
new file mode 100644
index 0000000..dc96036
--- /dev/null
+++ b/oppgaver/checkLetters.js
@@ -0,0 +1,22 @@
+const letters = "abcdefghijklmnopqrstuvwxzy ";
+let string = "Not a pangram";
+let string2 = "The quick brown fox jumps over the lazy dog"
+
+// console.log(letters, string,letterArray, stringArray,test)
+
+
+
+function isPangram(str) {
+ const lowerStr = str.toLowerCase();
+
+ if (letters.split('').every(char => lowerStr.includes(char))){
+ console.log('ja')
+ return true;
+
+ } else {
+ console.log('nei')
+ return false
+ };
+}
+
+isPangram(string2);
\ No newline at end of file