Kurs i webprogrammering: JavaScript

Modul 3 i programmeringskurset
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            
            <h1>HVA ER JAVASCRIPT</H1>
            
            <script>
                
                document.onclick = () => {
                    document.body.style.backgroundColor = "black";
                    document.body.innerHTML += "<h1>BØ</h1>";
                }
    let radius = 20; // En variabel
    const PI = 3.14; // En konstant
    
    radius = 100; // Endrer vi verdien til 
    
    console.log( PI * radius * radius);
    let tall = 23.847289;
    let forkortet = tall.toFixed(2);
    
    console.log(forkortet);
    console.log(typeof forkortet);
    let tilfeldig = Math.floor( Math.random() * 5 ) + 1;
    
    console.log(tilfeldig);
    function skrivLittTekst(tekst) {
        console.log(tekst);
    }
    
    const skrivTekst = () => {
        console.log("Du klikket på meg");
    }
    
    document.onclick = skrivTekst;
    
    const overskrift = document.querySelector("#overskrift");
    const minFarge = document.querySelector("#minFarge");
    
    overskrift.innerHTML = "VET IKKE";
    
    minFarge.oninput = () => {
        document.body.style.backgroundColor = minFarge.value; 
    }
    
    
    
    const inpTall1 = document.querySelector("#inpTall1");
    const inpTall2 = document.querySelector("#inpTall2");
    const txtSvar = document.querySelector("#txtSvar");
    
    const regnUt = () => {
        const tall1 = Number(inpTall1.value);
        const tall2 = Number(inpTall2.value);
        
        const svar = tall1 + tall2;
        txtSvar.innerHTML = svar;
    }
    
    inpTall1.oninput = regnUt;
    inpTall2.oninput = regnUt;
    const inpTall1 = document.querySelector("#inpTall1");
    const inpTall2 = document.querySelector("#inpTall2");
    const txtSvar = document.querySelector("#txtSvar");
    const valgtRegneart = document.querySelector("#valgtRegneart");
    
    
    const regnUt = () => {
        const tall1 = Number(inpTall1.value);
        const tall2 = Number(inpTall2.value);  
        const regneart = valgtRegneart.value;
         
        let svar;
        
        if(regneart === "+") {
    const firkanter = document.querySelector("#firkanter");
    
    let i = 1;
    
    while(i <= 100) {
        
        const firkant = document.createElement("div");
        firkanter.appendChild(firkant);
        
        firkant.style.opacity = 0.4;
        
        i++;    
    }
    
    body {
        height: 100vh;
        background-color: black;
        display: flex;
        align-items: center;
        justify-content: center;    
    }
    #firkanter {
        display: grid;
        grid-gap: 1px;
        grid-template-columns: repeat(10, 20px);
        grid-template-rows: repeat(10, 10px);
    }
    #firkanter div {    
    const handleliste = document.querySelector("#handleliste");
    
    const varer = [
        "Banan", 
        "Brød", 
        "Kaviar", 
        "Gulost"
    ];
    const priser = [23, 32, 23, 32];
    
    // Traversere et array
    
    for(const vare of varer) {
        
Gløer Langslet5:493 months ago
    const handleliste = document.querySelector("#handleliste");
    const txtSum = document.querySelector("#txtSum");
    
    const kaviar = {
      varenavn: "Mills Kaviar",
      pris: 28  
    };
    
    const gulost = {
        varenavn: "Tine Norvegia",
        pris: 49
    }
    
    const prim = {
    const handleliste = document.querySelector("#handleliste");
    const inpVare = document.querySelector("#inpVare");
    
    inpVare.onchange = () => {
        handleliste.innerHTML += `
            <li> ${inpVare.value} </li>
        `;
    }
    const handleliste = document.querySelector("#handleliste");
    const inpVare = document.querySelector("#inpVare");
    
    const varer = [];
    
    //varer.push("Banan");
    
    const visVarer = () => {
        handleliste.innerHTML = ""; // Nuller ut handlelisten
        for(const vare of varer) {
            
            handleliste.innerHTML += `
                <li>
                    ${vare}
    const sky = document.getElementById("sky");
    
    onscroll = () => {
        sky.style.left = scrollY - 180 + "px";    
    }
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            <h1>index.html</h1>
            <script src="index.pack.js"></script>
        </body>
    </html>
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            <h1>index.html</h1>
            <script src="index.pack.js"></script>
        </body>
    </html>
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            <h1>index.html</h1>
            <script src="index.pack.js"></script>
        </body>
    </html>
    console.log("Hello from JavaScript");
    const passord = "banan";
    
    let inputFraBruker = ;
    
    if(inputFraBruker === passord) {
        console.log("Du har skrevet riktig passord. Kom inn!!!!");
    } else {
        console.log("Feil passord! Prøv igjen!!!!");
    }
    let tall = 23.847289;
    let forkortet = tall.toFixed(2);
    
    console.log(forkortet);
    console.log(typeof forkortet);
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            <h1>Nettbanken</h1>
            
            <script src="index.pack.js"></script>
        </body>
    </html>
    html {
        font-size: 100%;
    }
    
    body {
        background-color: #eee;
        font-family: sans-serif;
    }
    
    main {
        max-width: 700px;
        margin: auto;
        padding: 1rem;
        background-color: white;
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            
            <main>
                <div id="boet">
                    <div id="blue"></div>
                    <div id="white"></div>
                    <div id="red"></div>
                    <div id="white_inner"></div>
                </div>