lena_neko
lena_neko
KPCKevin Powell - Community
Created by lena_neko on 10/30/2023 in #front-end
How do I give the input the remaining space?
No description
11 replies
KPCKevin Powell - Community
Created by lena_neko on 10/23/2023 in #front-end
Advice Slip JSON API not working properly?
I'm doing the Frontend Mentor Challenge: Advice Generator which they say uses the API from the title. It says on their site that a new piece of advice can be fetched every 2 seconds. But when I click on my button to fetch my new advice it only gives me the same piece of advice for like several minutes and only then changing it up. I don't have any Network Errors only 200 Status returns after every button click. I don't think I have done anything wrong but the requested entry point also returns new advice after 2 seconds: https://api.adviceslip.com/advice
const adviceNumberEl = document.querySelector("#advice-id");
const adviceTextEl = document.querySelector("#advice-text");
const btn = document.querySelector("#btn");

async function getAdvice() {
try {
const res = await fetch("https://api.adviceslip.com/advice");
const data = await res.json();
adviceNumberEl.textContent = data.slip.id;
adviceTextEl.textContent = data.slip.advice;
} catch (error) {
console.log(error);
}
}

btn.addEventListener("click", getAdvice);
const adviceNumberEl = document.querySelector("#advice-id");
const adviceTextEl = document.querySelector("#advice-text");
const btn = document.querySelector("#btn");

async function getAdvice() {
try {
const res = await fetch("https://api.adviceslip.com/advice");
const data = await res.json();
adviceNumberEl.textContent = data.slip.id;
adviceTextEl.textContent = data.slip.advice;
} catch (error) {
console.log(error);
}
}

btn.addEventListener("click", getAdvice);
5 replies
KPCKevin Powell - Community
Created by lena_neko on 10/3/2023 in #front-end
I would like some constructive feedback
I am currently doing the Frontend Mentor Challenge "Age Calculator" (https://www.frontendmentor.io/challenges/age-calculator-app-dF9DFFpj-Q) and I'd appreciate some constructive feedback about my CSS and JavaScript: https://codepen.io/lena-s98/pen/GRPGXOe But please avoid opinionated feedback like "Don't use comments", etc ... I'm struggling to get the age calculation to work correctly. Maybe someone can nudge me into the right direction 🙂
18 replies
KPCKevin Powell - Community
Created by lena_neko on 2/12/2023 in #front-end
How to remove a value when you click outside of a button?
When I click a button I select the ratings value but when i click outside of the buttons I want to remove that value from the variable. I tried if .hasFocus() and .activeElement is false (probably did it wrong too) then change the variable to undefined but it didn't work for now. https://stackblitz.com/edit/web-platform-gffhc4?file=script.js
6 replies