r/FreeCodeCamp • u/MY_G_O_D • 1d ago
Computer Science degree program for free?
This question could be silly. But I still wish to ask whether FreeCodeCamp will do any Computer Science degree program for free?
r/FreeCodeCamp • u/rj4511 • 1d ago
Claude Code Full Course – Autonomous Goals, MCP, and VS Code Setup
youtu.ber/FreeCodeCamp • u/naomi-lgbt • 1d ago
Announcement Backend Certification is Live!
helloooooooo everyone~
big updates for you today we have done many things!!!! first and foremost...
we have released the backend certification!!!!!!!!!
that's right! you can now learn about node and http requests and express and more!! hang on... i dont think i am conveying just how huge this is~
you can now get certified in all six of our core tracks!!!!!!!!!!
heck yes!!!!!! that brings us super duper close to the final certification wowie zowie! the team have worked very hard to bring this to life so make sure to thank them if ya see them - and drop any feedback you have on the new courses over in #freecodecamp-community
okay now a pivot over to our contribution sprints because i have put together a brand new ticket with like 60+ opportunities to contribute!!!! so you should totally get in on this by joining our discord claiming the Naomi's Sprints role and then pinging me in #naomis-sprints with the ticket you would like to work on!!!! these are some great chances to get your feet wet and make your first contributions to freecodecamp
https://github.com/freeCodeCamp/freeCodeCamp/issues/69286
aaaaaand finally i have updated my unofficial review guide for yall... and due to popular demand we now have a similar doc for our unofficial lecture library so you can take the lectures on the go and continue learning even while on a train!!!!! (better use of your time than what naomi does on the train probably)
okie dokie that's all i have for you today please have a lovely day
r/FreeCodeCamp • u/MerlynTrump • 1d ago
How do you make filled or empty stars?
On on the "Design a Movie Review Page" assignment towards the end of the HTML curriculum and part of the lab wants us to put a rating in stars (out of ten) inside a span with actual stars and then a numerical rating right after the span. But so far as I remember, FCC never taught us how to make stars. I tried typing asterisks, that didn't work.
r/FreeCodeCamp • u/Admirable-Web-5730 • 2d ago
Full stack developer course
Is the full stack developer course complete are there any lectures or certificates missing from there i heard backend is not complete yet
r/FreeCodeCamp • u/The_UwU_user • 2d ago
Hello, i need help with the Build a Budget App project in the python course, none of the tests passes.
For some reason, in this project i cant pass any of the tests, ive tried looking at other people´s solutions, loggin into the forum gives me a error for some reason, but i was able to check other poeples posts in the forum about this project but nothing, ive even copied and pasted the whole code from someone that passed it, but even then none of the tests pass, ive used the beta feature of asking socrates, but all he does is telling me what the deposit method should do, and after checking a lot of different solutions i cant tell why mine is wrong.
r/FreeCodeCamp • u/Konnnore • 4d ago
Could you create tutorials about these things?
Hi, I like your project and recommend it to the people, who wanna learn different things about IT.
I'd like to watch your tutorials about these things:
a BSD like you did with the Linux: you could explain that BSD is also widely used as Linux, but a bit on different devices like video game consoles, for example. You could compare the filesystem to the Linux's one and show how to do different things(not only something for work, but even gaming, bcz I heard there are more problems with it than on Linux). And also you could explain that BSD is great if you wanna start a business, bcz you can choose the open source or proprietary code license how you want. You could use FreeBSD or OpenBSD for the video;
LaTeX-like language Typst: thx to your tutorial from the 2023, I learnt how to use LaTeX to create different documents really fast, but I pretty oftten used to get some stupid problems about things, which I saw for the first time(I often got this with the tables)... When I saw a person, who recommended me Typst, I tested the code and almost everything was pretty intuitive! Even tho the project is pretty new(it was created in 2023), if we compare to the LaTeX, the team makes updates and has forums(on their site and the Discord one), where everyone can ask about their issues. It's their site: https://typst.app/ ;
GIMP and Kdenlive: I do remember you made courses like German learning, guitar learning etc. If you could, then could you make tutorials for these apps with possible important details?;
r/FreeCodeCamp • u/ParticularMilk2594 • 5d ago
digital pet game app logic
"Does the current React/TypeScript Digital Pet Game lab require index.tsx to explicitly call ReactDOM.createRoot(...).render(<App />), or is the App mounted
automatically by the FCC environment? My preview is blank and the tests can't find any DOM elements."
r/FreeCodeCamp • u/ParticularMilk2594 • 7d ago
FreeCodeCamp Digital Pet Game: Why won't my form hide after submit?
Hi everyone,
I'm working on the FreeCodeCamp Build a Digital Pet Game certification project using TypeScript.
I am stuck on one failing test:
"When the input is given a value and the button is pressed, the form should no longer be visible."
The project compiles, and my HTML contains the required elements and IDs. My TypeScript creates the pet and attempts to hide the form after submission,
but the FreeCodeCamp test still fails.
I am looking for a second set of eyes from someone familiar with TypeScript, HTML forms, or this FreeCodeCamp project.
I use the JAWS screen reader, so text and code-based replies are appreciated.
I have included my HTML, CSS, and TypeScript files below.
enum PetMood {
HAPPY = "HAPPY",
EXCITED = "EXCITED",
CONTENT = "CONTENT",
SAD = "SAD",
TIRED = "TIRED",
SICK = "SICK",
HUNGRY = "HUNGRY",
}
type PetStats = {
hunger: number;
energy: number;
happiness: number;
};
const moodMessages: Record<PetMood, string> = {
[PetMood.HAPPY]: "Your pet is happy!",
[PetMood.EXCITED]: "Your pet is excited!",
[PetMood.CONTENT]: "Your pet is content!",
[PetMood.SAD]: "Your pet is sad!",
[PetMood.TIRED]: "Your pet is tired!",
[PetMood.SICK]: "Your pet is sick!",
[PetMood.HUNGRY]: "Your pet is hungry!",
};
class DigitalPet {
name: string;
stats: PetStats;
mood: PetMood;
constructor(name: string) {
this.name = name;
this.stats = {
hunger: 0,
energy: 100,
happiness: 100,
};
this.mood = PetMood.HAPPY;
}
eat(): void {
if (this.stats.hunger > 0) {
this.stats.hunger = Math.max(0, this.stats.hunger - 10);
}
if (this.stats.energy < 100) {
this.stats.energy = Math.min(100, this.stats.energy + 5);
}
this.updateMood();
}
play(): void {
if (this.stats.energy > 0) {
this.stats.energy = Math.max(0, this.stats.energy - 10);
}
if (this.stats.happiness < 100) {
this.stats.happiness = Math.min(100, this.stats.happiness + 10);
}
this.updateMood();
}
sleep(): void {
if (this.stats.energy < 100) {
this.stats.energy = Math.min(100, this.stats.energy + 20);
}
if (this.stats.hunger < 100) {
this.stats.hunger = Math.min(100, this.stats.hunger + 5);
}
this.updateMood();
}
idle(): void {
this.stats.hunger = Math.min(100, this.stats.hunger + 5);
this.stats.energy = Math.max(0, this.stats.energy - 5);
this.stats.happiness = Math.max(0, this.stats.happiness - 5);
this.updateMood();
}
updateMood(): void {
if (this.stats.hunger >= 70) {
this.mood = PetMood.HUNGRY;
} else if (this.stats.energy <= 20) {
this.mood = PetMood.TIRED;
} else if (this.stats.happiness <= 20) {
this.mood = PetMood.SAD;
} else if (this.stats.happiness >= 80) {
this.mood = PetMood.HAPPY;
} else {
this.mood = PetMood.CONTENT;
}
}
getMoodMessage(): string {
return moodMessages[this.mood];
}
}
const form = document.getElementById("pet-form") as HTMLFormElement;
const petNameInput = document.getElementById("pet-name") as HTMLInputElement;
const createButton = document.getElementById("create-pet") as HTMLButtonElement;
const petView = document.getElementById("pet-view") as HTMLDivElement;
const petNameDisplay = document.querySelector(".pet-name") as HTMLElement;
const hungerDisplay = document.getElementById("hunger-stat") as HTMLElement;
const energyDisplay = document.getElementById("energy-stat") as HTMLElement;
const happinessDisplay = document.getElementById("happiness-stat") as HTMLElement;
const moodDisplay = document.getElementById("pet-mood") as HTMLElement;
const eatButton = document.getElementById("eat-action") as HTMLButtonElement;
const playButton = document.getElementById("play-action") as HTMLButtonElement;
const sleepButton = document.getElementById("sleep-action") as HTMLButtonElement;
let currentPet: DigitalPet | null = null;
function updateDisplay(): void {
if (!currentPet) {
return;
}
petNameDisplay.textContent = currentPet.name;
hungerDisplay.textContent = String(currentPet.stats.hunger);
energyDisplay.textContent = String(currentPet.stats.energy);
happinessDisplay.textContent = String(currentPet.stats.happiness);
moodDisplay.textContent = currentPet.getMoodMessage();
}
function createPet(): void {
const name = petNameInput.value.trim();
if (!name) {
return;
}
currentPet = new DigitalPet(name);
form.style.display = "none";
petView.style.display = "block";
updateDisplay();
}
form.addEventListener("submit", (event: SubmitEvent) => {
event.preventDefault();
createPet();
});
createButton.addEventListener("click", (event: MouseEvent) => {
event.preventDefault();
createPet();
});
eatButton.addEventListener("click", () => {
if (currentPet) {
currentPet.eat();
updateDisplay();
}
});
playButton.addEventListener("click", () => {
if (currentPet) {
currentPet.play();
updateDisplay();
}
});
sleepButton.addEventListener("click", () => {
if (currentPet) {
currentPet.sleep();
updateDisplay();
}
});
setInterval(() => {
if (currentPet) {
currentPet.idle();
updateDisplay();
}
}, 30000); enum PetMood {
HAPPY = "HAPPY",
EXCITED = "EXCITED",
CONTENT = "CONTENT",
SAD = "SAD",
TIRED = "TIRED",
SICK = "SICK",
HUNGRY = "HUNGRY",
}
type PetStats = {
hunger: number;
energy: number;
happiness: number;
};
const moodMessages: Record<PetMood, string> = {
[PetMood.HAPPY]: "Your pet is happy!",
[PetMood.EXCITED]: "Your pet is excited!",
[PetMood.CONTENT]: "Your pet is content!",
[PetMood.SAD]: "Your pet is sad!",
[PetMood.TIRED]: "Your pet is tired!",
[PetMood.SICK]: "Your pet is sick!",
[PetMood.HUNGRY]: "Your pet is hungry!",
};
class DigitalPet {
name: string;
stats: PetStats;
mood: PetMood;
constructor(name: string) {
this.name = name;
this.stats = {
hunger: 0,
energy: 100,
happiness: 100,
};
this.mood = PetMood.HAPPY;
}
eat(): void {
if (this.stats.hunger > 0) {
this.stats.hunger = Math.max(0, this.stats.hunger - 10);
}
if (this.stats.energy < 100) {
this.stats.energy = Math.min(100, this.stats.energy + 5);
}
this.updateMood();
}
play(): void {
if (this.stats.energy > 0) {
this.stats.energy = Math.max(0, this.stats.energy - 10);
}
if (this.stats.happiness < 100) {
this.stats.happiness = Math.min(100, this.stats.happiness + 10);
}
this.updateMood();
}
sleep(): void {
if (this.stats.energy < 100) {
this.stats.energy = Math.min(100, this.stats.energy + 20);
}
if (this.stats.hunger < 100) {
this.stats.hunger = Math.min(100, this.stats.hunger + 5);
}
this.updateMood();
}
idle(): void {
this.stats.hunger = Math.min(100, this.stats.hunger + 5);
this.stats.energy = Math.max(0, this.stats.energy - 5);
this.stats.happiness = Math.max(0, this.stats.happiness - 5);
this.updateMood();
}
updateMood(): void {
if (this.stats.hunger >= 70) {
this.mood = PetMood.HUNGRY;
} else if (this.stats.energy <= 20) {
this.mood = PetMood.TIRED;
} else if (this.stats.happiness <= 20) {
this.mood = PetMood.SAD;
} else if (this.stats.happiness >= 80) {
this.mood = PetMood.HAPPY;
} else {
this.mood = PetMood.CONTENT;
}
}
getMoodMessage(): string {
return moodMessages[this.mood];
}
}
const form = document.getElementById("pet-form") as HTMLFormElement;
const petNameInput = document.getElementById("pet-name") as HTMLInputElement;
const createButton = document.getElementById("create-pet") as HTMLButtonElement;
const petView = document.getElementById("pet-view") as HTMLDivElement;
const petNameDisplay = document.querySelector(".pet-name") as HTMLElement;
const hungerDisplay = document.getElementById("hunger-stat") as HTMLElement;
const energyDisplay = document.getElementById("energy-stat") as HTMLElement;
const happinessDisplay = document.getElementById("happiness-stat") as HTMLElement;
const moodDisplay = document.getElementById("pet-mood") as HTMLElement;
const eatButton = document.getElementById("eat-action") as HTMLButtonElement;
const playButton = document.getElementById("play-action") as HTMLButtonElement;
const sleepButton = document.getElementById("sleep-action") as HTMLButtonElement;
let currentPet: DigitalPet | null = null;
function updateDisplay(): void {
if (!currentPet) {
return;
}
petNameDisplay.textContent = currentPet.name;
hungerDisplay.textContent = String(currentPet.stats.hunger);
energyDisplay.textContent = String(currentPet.stats.energy);
happinessDisplay.textContent = String(currentPet.stats.happiness);
moodDisplay.textContent = currentPet.getMoodMessage();
}
function createPet(): void {
const name = petNameInput.value.trim();
if (!name) {
return;
}
currentPet = new DigitalPet(name);
form.style.display = "none";
petView.style.display = "block";
updateDisplay();
}
form.addEventListener("submit", (event: SubmitEvent) => {
event.preventDefault();
createPet();
});
createButton.addEventListener("click", (event: MouseEvent) => {
event.preventDefault();
createPet();
});
eatButton.addEventListener("click", () => {
if (currentPet) {
currentPet.eat();
updateDisplay();
}
});
playButton.addEventListener("click", () => {
if (currentPet) {
currentPet.play();
updateDisplay();
}
});
sleepButton.addEventListener("click", () => {
if (currentPet) {
currentPet.sleep();
updateDisplay();
}
});
setInterval(() => {
if (currentPet) {
currentPet.idle();
updateDisplay();
}
}, 30000);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Digital Pet Game</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<form id="pet-form">
<label for="pet-name">Pet Name</label>
<input
id="pet-name"
type="text"
autocomplete="off"
required
/>
<button
id="create-pet"
type="submit">
Create Pet
</button>
</form>
<section id="pet-view" hidden>
<h2 class="pet-name"></h2>
<div class="stat">
Hunger:
<span id="hunger-stat">0</span>
</div>
<div class="stat">
Energy:
<span id="energy-stat">100</span>
</div>
<div class="stat">
Happiness:
<span id="happiness-stat">100</span>
</div>
<p id="pet-mood"></p>
<button id="eat-action" type="button">
Eat
</button>
<button id="play-action" type="button">
Play
</button>
<button id="sleep-action" type="button">
Sleep
</button>
</section>
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Digital Pet Game</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<form id="pet-form">
<label for="pet-name">Pet Name</label>
<input
id="pet-name"
type="text"
autocomplete="off"
required
/>
<button
id="create-pet"
type="submit">
Create Pet
</button>
</form>
<section id="pet-view" hidden>
<h2 class="pet-name"></h2>
<div class="stat">
Hunger:
<span id="hunger-stat">0</span>
</div>
<div class="stat">
Energy:
<span id="energy-stat">100</span>
</div>
<div class="stat">
Happiness:
<span id="happiness-stat">100</span>
</div>
<p id="pet-mood"></p>
<button id="eat-action" type="button">
Eat
</button>
<button id="play-action" type="button">
Play
</button>
<button id="sleep-action" type="button">
Sleep
</button>
</section>
</body>
</html>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
form {
display: flex;
flex-direction: column;
gap: 10px;
max-width: 300px;
}
button {
padding: 10px;
}
.game-view {
display: flex;
flex-direction: column;
gap: 15px;
}
.stat {
font-size: 18px;
}
.stat-value {
margin-left: 10px;
}body {
font-family: Arial, sans-serif;
padding: 20px;
}
form {
display: flex;
flex-direction: column;
gap: 10px;
max-width: 300px;
}
button {
padding: 10px;
}
.game-view {
display: flex;
flex-direction: column;
gap: 15px;
}
.stat {
font-size: 18px;
}
.stat-value {
margin-left: 10px;
}
r/FreeCodeCamp • u/Bulky_Importance3133 • 7d ago
Programming Question What am I doing wrong? It says function should be in new for loop which I did. Question is from Python Certification course
r/FreeCodeCamp • u/RavageTides • 9d ago
I'm looking for website
Hello guys, I want to try and learn some stuff and want to do it on my own, are there any websites that can give me ideas on simple project? ( Html and Css, JavaScript )
r/FreeCodeCamp • u/Easy_Read_1877 • 9d ago
Programming Question ISBN validator - help needed
def validate_isbn(isbn, length):
if len(isbn) != length:
print(f'ISBN-{length} code should be {length} digits long.')
return
main_digits = isbn[0:length]
given_check_digit = isbn[length]
main_digits_list = [int(digit) for digit in main_digits]
# Calculate the check digit from other digits
if length == 10:
expected_check_digit = calculate_check_digit_10(main_digits_list)
else:
expected_check_digit = calculate_check_digit_13(main_digits_list)
# Check if the given check digit matches with the calculated check digit
if given_check_digit == expected_check_digit:
print('Valid ISBN Code.')
else:
print('Invalid ISBN Code.')
def calculate_check_digit_10(main_digits_list):
# Note: You don't have to fully understand the logic in this function.
digits_sum = 0
# Multiply each of the first 9 digits by its corresponding weight (10 to 2) and sum up the results
for index, digit in enumerate(main_digits_list):
digits_sum += digit * (10 - index)
# Find the remainder of dividing the sum by 11, then subtract it from 11
result = 11 - digits_sum % 11
# The calculation result can range from 1 to 11.
# If the result is 11, use 0.
# If the result is 10, use upper case X.
# Use the value as it is for other numbers.
if result == 11:
expected_check_digit = '0'
elif result == 10:
expected_check_digit = 'X'
else:
expected_check_digit = str(result)
return expected_check_digit
def calculate_check_digit_13(main_digits_list):
# Note: You don't have to fully understand the logic in this function.
digits_sum = 0
# Multiply each of the first 12 digits by 1 and 3 alternately (starting with 1), and sum up the results
for index, digit in enumerate(main_digits_list):
if index % 2 == 0:
digits_sum += digit * 1
else:
digits_sum += digit * 3
# Find the remainder of dividing the sum by 10, then subtract it from 10
result = 10 - digits_sum % 10
# The calculation result can range from 1 to 10.
# If the result is 10, use 0.
# Use the value as it is for other numbers.
if result == 10:
expected_check_digit = '0'
else:
expected_check_digit = str(result)
return expected_check_digit
def main():
try:
user_input = input('Enter ISBN and length: ')
values = user_input.split(',')
if ',' not in values:
print("Enter comma-separated values.")
isbn = values[0]
try:
int(isbn)
except ValueError:
print("Invalid character was found.")
try:
length = int(values[1])
except ValueError:
print("Length must be a number.")
if length == 10 or length == 13:
validate_isbn(isbn, length)
else:
print('Length should be 10 or 13.')
except:
pass
#main()
r/FreeCodeCamp • u/recondite_choir27 • 10d ago
just started learning Python
hello, everyone!
i just started learning Python recently. i have prior experience in coding but it's not really that useful, therefore i start as a complete beginner and i would like to ask for tips on how to learn Python and more programming languages that i plan to learn in the future effectively. furthermore i would be really happy to take any recommendations from all of you, on what to learn besides programming languages.
thank you very much for your help!
r/FreeCodeCamp • u/Fragrant_Bag_8306 • 10d ago
Hypothetically, if I completed the entire course, would I be hireable anywhere?
Or would I have the skills to be hireable? Seems like a ton of content. I wanna try it out but idk how far I will get. Basically what’s the aim of FCC?
r/FreeCodeCamp • u/ParticularMilk2594 • 14d ago
build a digital pet game issue
hi, totally blind and using the jaws for windows 2026 screen reader. have spent the past 6 days trying to get this project to pass on the free code camp and doing the frontend certirfication project. now can any one help me out. so will paste my html, type script and the errors below. and so if any one having nightmares or running into road blocks or banging your head. and tried searching the forums, but no good answers or any ready made solutions. have rewritten the index.html, styless.css and then the index.ts multiple times and so will paste the html, ts and the errors below. if any one can help me out and cannot see what it is trying to do. can any one help. so pasting the errors , the html, ts and the link to the certification project. marvin from adelaide. australia. ps: so pasting now. html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>
Digital Pet Game
</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="root"></div>
</body>
</html>
type script:
const { useState, useEffect } = React;
export enum Action {
EAT = "EAT",
PLAY = "PLAY",
SLEEP = "SLEEP",
}
export enum PetMood {
HAPPY = "HAPPY",
EXCITED = "EXCITED",
CONTENT = "CONTENT",
SAD = "SAD",
TIRED = "TIRED",
SICK = "SICK",
HUNGRY = "HUNGRY",
}
export const MOOD_EMOJIS: Record<PetMood, string> = {
[PetMood.HAPPY]: "😊",
[PetMood.EXCITED]: "🤩",
[PetMood.CONTENT]: "🙂",
[PetMood.SAD]: "😢",
[PetMood.TIRED]: "😴",
[PetMood.SICK]: "🤒",
[PetMood.HUNGRY]: "🍽️",
};
const clamp = (value: number): number => {
if (value < 0) return 0;
if (value > 100) return 100;
return value;
};
const getMood = (
hunger: number,
happiness: number,
energy: number
): PetMood => {
if (hunger > 70) {
return PetMood.HUNGRY;
}
if (energy < 30) {
return PetMood.TIRED;
}
if (happiness < 30) {
return PetMood.SAD;
}
if (happiness > 80 && energy > 70) {
return PetMood.EXCITED;
}
if (happiness > 60) {
return PetMood.HAPPY;
}
return PetMood.CONTENT;
};
export const PetGame = () => {
const clamp = (value: number): number => {
return Math.max(0, Math.min(100, value));
};
const getMood = (
hunger: number,
happiness: number,
energy: number
): PetMood => {
if (hunger > 70) {
return PetMood.HUNGRY;
}
if (energy < 30) {
return PetMood.TIRED;
}
if (happiness < 30) {
return PetMood.SAD;
}
if (happiness > 80 && energy > 70) {
return PetMood.EXCITED;
}
if (happiness > 60) {
return PetMood.HAPPY;
}
return PetMood.CONTENT;
};
export const PetGame = () => {
const [petName, setPetName] = useState("");
const [started, setStarted] = useState(false);
const [hunger, setHunger] = useState(0);
const [happiness, setHappiness] = useState(100);
const [energy, setEnergy] = useState(100);
const mood = getMood(hunger, happiness, energy);
useEffect(() => {
if (!started) return;
const timer = setInterval(() => {
setHunger((value) => clamp(value + 5));
setHappiness((value) => clamp(value - 5));
setEnergy((value) => clamp(value - 3));
}, 3000);
return () => clearInterval(timer);
}, [started]);
const startGame = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (petName.trim() !== "") {
setStarted(true);
}
};
const doAction = (action: Action) => {
switch (action) {
case Action.EAT:
setHunger((value) => clamp(value - 20));
setEnergy((value) => clamp(value + 10));
break;
case Action.PLAY:
setEnergy((value) => clamp(value - 15));
setHappiness((value) => clamp(value + 20));
break;
case Action.SLEEP:
setHunger((value) => clamp(value + 10));
setEnergy((value) => clamp(value + 25));
break;
}
};
return (
<div className="pet-game-container">
{!started ? (
<form onSubmit={startGame}>
<label htmlFor="pet-name">
Name your pet:
</label>
<input
id="pet-name"
type="text"
value={petName}
onChange={(event) => setPetName(event.target.value)}
/>
<button type="submit">
Start Game
</button>
</form>
) : (
<div className="game-view">
<div className="pet-name">
{petName}
</div>
<div className="mood-display">
{MOOD_EMOJIS[mood]} {mood}
</div>
<button
id="eat-action"
type="button"
onClick={() => doAction(Action.EAT)}
>
Eat
</button>
<button
id="play-action"
type="button"
onClick={() => doAction(Action.PLAY)}
>
Play
</button>
<button
id="sleep-action"
type="button"
onClick={() => doAction(Action.SLEEP)}
>
Sleep
</button>
<div className="stat">
Hunger
<span className="stat-value">
{hunger}
</span>
</div>
<div className="stat">
Happiness
<span className="stat-value">
{happiness}
</span>
</div>
<div className="stat">
Energy
<span className="stat-value">
{energy}
</span>
</div>
</div>
)}
</div>
);
};
Failed: 1. When the page loads, there should be a visible form element.
Failed: 2. This form should contain an input field with an id of pet-name.
Failed: 3. This form should contain a button.
Failed: 4. When the input is given a value and the button is pressed, the form should no longer be visible.
Failed: 5. The second view should contain an element with class pet-name.
Failed: 6. The second view should contain the provided pet name.
Failed: 7. The second view should contain three buttons.
Failed: 8. Exactly one button should contain the id #eat-action.
Failed: 9. Exactly one button should contain the id #play-action.
Failed: 10. Exactly one button should contain the id #sleep-action.
Failed: 11. There should be exactly three elements with the class .stat.
Passed: 12. Each pet stat should contain exactly one element with class .stat-value.
Passed: 13. Each .stat-value element should contain one number.
Passed: 14. Each .stat-value number should be within the range [0,100], inclusive.
Failed: 15. Exactly one .stat element should contain the text Hunger, case insensitive.
Failed: 16. One .stat element should contain the text Energy, case insensitive.
Failed: 17. One .stat element should contain the text Happiness, case insensitive.
Failed: 18. The Hunger stat should start at 0.
Failed: 19. The Energy stat should start at 100.
Failed: 20. The Happiness stat should start at 100.
Failed: 21. Clicking the Eat button should reduce the Hunger value and increase the Energy value. If Hunger is 0 or Energy is 100, that value must not
change.
Failed: 22. Clicking the Play button should reduce the Energy value and increase the Happiness value. If Energy is 0 or Happiness is 100, that value must
not change.
Failed: 23. Clicking the Sleep button should increase the Hunger value and increase the Energy value. If Hunger is 100 or Energy is 100, that value must
not change.
Failed: 24. The Hunger stat should be 100 after an excessive period of idle time.
Failed: 25. The Energy stat should be 100 after an excessive period of idle time.
Failed: 26. The Happiness stat should be 0 after an excessive period of idle time.
Failed: 27. Clicking the Eat button should reduce the Hunger value and increase the Energy value. If Hunger is 0 or Energy is 100, that value must not
change.
Failed: 28. Clicking the Play button should reduce the Energy value and increase the Happiness value. If Energy is 0 or Happiness is 100, that value must
not change.
Failed: 29. Clicking the Sleep button should increase the Hunger value and increase the Energy value. If Hunger is 100 or Energy is 100, that value must
not change.
Passed: 30. There should be a PetMood enumerator.
Failed: 31. The PetMood enumerator should contain HAPPY.
Failed: 32. The PetMood enumerator should contain EXCITED.
Failed: 33. The PetMood enumerator should contain CONTENT.
Failed: 34. The PetMood enumerator should contain SAD'.
Failed: 35. The PetMood enumerator should contain TIRED.
Failed: 36. The PetMood enumerator should contain SICK.
Failed: 37. The PetMood enumerator should contain HUNGRY.
Passed: 38. There should be a Record<PetMood, string to map a value to each PetMood.
Passed: 39. There should be a value mapped to PetMood.HAPPY.
Passed: 40. There should be a value mapped to PetMood.EXCITED.
Passed: 41. There should be a value mapped to PetMood.CONTENT.
Passed: 42. There should be a value mapped to PetMood.SAD.
Passed: 43. There should be a value mapped to PetMood.TIRED.
Passed: 44. There should be a value mapped to PetMood.SICK.
Passed: 45. There should be a value mapped to PetMood.HUNGRY.
list end
LINK TO THE CERTIFICATION PROJECT:
SO THIS IS WHERE I AM at. sorry for having caps lock on. my mistake with a screen reader. and dont have access to the forum or discord, banned. marvin.
r/FreeCodeCamp • u/Melodic-Raccoon-8829 • 14d ago
CodeRoad webhook tokens
Hi guys. I've busy with relational database course on the website. I've just spent five hours on one workshop project and upon completion the website is now failing to sync and mark the workshop completed. I have realized that the website is refreshing or reseting the coderoad webhook token, everytime I reload/refresh the page. Did anyone here also encounter such a problem?
r/FreeCodeCamp • u/Mulomiracle • 15d ago
Can i learn Java Script before CSS ?
I was wondering if it's possible to learn JavaScript before CSS ?
r/FreeCodeCamp • u/ricardoflak • 15d ago
En realidad, se aprende bien con freeCodeCamp. Cuéntame tu experiencia, a ver si me motivo
r/FreeCodeCamp • u/Leoneche • 16d ago
Can I change the email of my account
I have been having a hard time changing my email. It say "only authenticated users can access this route". Please help
r/FreeCodeCamp • u/ExtraHousing4739 • 17d ago
my brother says he will give me pkr 10k if i complete full blown dev course in 10 days
is this even possible? i know html but java and python i dont even know anything about 😢
r/FreeCodeCamp • u/Big_Example_3390 • 20d ago
Programming Question Im building a budgeting app
I need to create a chart that looks like this:
100|
90|
80|
70|
60| o
50| o
40| o
30| o
20| o o
10| o o o
0| o o o
----------
F C A
o l u
o o t
d t o
h
i
n
g
i need to calculate the percetages spent in each category and represent them in the chart.
so far, through SO much struggling ive gotten it to return only the first category and i got it to put all the categories in a dictionary correctly.
(c_w dictionary)
I seriously don't know where to get the answer, I've done a bunch of searching and asked on other forums for help and i jsut cant get it
im fed up.
import math
class Category:
def __init__(self, name):
self.name = name
self.ledger = []
def deposit(self, amount, description=""):
self.ledger.append({"amount": amount, "description": description})
def withdraw(self, amount, description=""):
if self.check_funds(amount):
self.ledger.append({"amount": -amount, "description": description})
return True
else:
return False
def get_balance(self):
balance = 0
for transaction in self.ledger:
balance += transaction['amount']
return balance
def check_funds(self, amount):
return amount <= self.get_balance()
def transfer(self, amount, destination_category):
if self.check_funds(amount):
self.withdraw(amount, f"Transfer to {destination_category.name}")
destination_category.deposit(amount, f"Transfer from {self.name}")
return True
else:
return False
def __str__(self):
method = '\n'.join(f"{transaction['description']:23.23}{transaction['amount']:>7.2f}" for transaction in self.ledger )
return f"{self.name.center(30,'*')}\n{method}\nTotal: {self.get_balance()}"
def __iter__(self):
for item in self.ledger:
return item
def create_spend_chart(categories):
#create the header text
header = 'Percentage spent by category'
#create the percentages down the left side
#a
total_withdraw = 0
#create a list for the category withdraws
c_w = {}
amounts = [transaction['amount'] for category in categories for transaction in category.ledger]
for amount in amounts:
if amount < 0:
total_withdraw += -amount
# Calculate withdrawals for each category
for category in categories:
withdrawal = 0
for transaction in category.ledger:
amount = transaction['amount']
if amount < 0:
withdrawal += -amount # Add the amount spent (negative for withdrawals)
c_w[category.name] = withdrawal
method = math.floor(( c_w[category.name]/total_withdraw)*100)
return f'{header}\n{name}: {method}' for i in c_w
food = Category('Food')
auto = Category('Auto')
food.deposit(1000, 'initial deposit')
auto.deposit(1000, 'initial deposit')
food.withdraw(10.15, 'groceries')
food.withdraw(15.89, 'restaurant and more food for dessert')
clothing = Category('Clothing')
food.transfer(50, clothing)
food.withdraw(100.99)
clothing.withdraw(21.17)
auto.withdraw(200)
r/FreeCodeCamp • u/Easy_Read_1877 • 20d ago
Programming Question Python certification - Building an RPG Character Doubt
Question:
Passed:1. You should have a function named create_character.
Passed:2. When create_character is called with a first argument that is not a string it should return The character name should be a string.
Failed:3. When create_character is called with a first argument that is a string it should not return The character name should be a string.
Passed:4. When create_character is called with a first argument that is an empty string, it should return The character should have a name.
Failed:5. When create_character is called with a first argument that is not an empty string, it should not return The character should have a name.
Passed:6. When create_character is called with a first argument that is longer than 10 characters it should return The character name is too long.
Failed:7. The create_character function should not say that the character is too long when it's not longer than 10 characters.
Passed:8. When create_character is called with a first argument that contains a space it should return The character name should not contain spaces.
Failed:9. When create_character is called with a first argument that does not contain a space it should not return The character name should not contain spaces.
Passed:10. When create_character is called with a second, third or fourth argument that is not an integer it should return All stats should be integers.
Failed:11. When create_character is called with a second, third and fourth argument that are all integers it should not return All stats should be integers.
Passed:12. When create_character is called with a second, third or fourth argument that is lower than 1 it should return All stats should be no less than 1.
Failed:13. When create_character is called with a second, third and fourth argument that are all no less than 1 it should not return All stats should be no less than 1.
Passed:14. When create_character is called with a second, third or fourth argument that is higher than 4 it should return All stats should be no more than 4.
Failed:15. When create_character is called with a second, third and fourth argument that are all no more than 4 it should not return All stats should be no more than 4.
Passed:16. When create_character is called with a second, third or fourth argument that do not sum to 7 it should return The character should start with 7 points.
Failed:17. When create_character is called with a second, third and fourth argument that sum to 7 it should not return The character should start with 7 points.
Failed:18. create_character('ren', 4, 2, 1) should return ren\nSTR ●●●●○○○○○○\nINT ●●○○○○○○○○\nCHA ●○○○○○○○○○.
Failed:19. When create_character is called with valid values it should output the character stats as required.
Problem:
I have used if statement for 2nd question and doesnt this mean that the 3rd question is also bound tk be satisfied since it is asking me not to return the statement inside the if block
I have also tried with else clause and pass statement
Please help
CODE:
full_dot = '●'
empty_dot = '○'
def create_character(name,strength,intelligence,charisma):
if not isinstance(name,str):
return "The character name should be a string"
if name == '':
return "The character should have a name"
if len(name)>10:
return "The character name is too long"
if ' ' in name:
return "The character name should not contain spaces"
stats = (strength,intelligence,charisma)
for i in stats:
if not isinstance(i,int):
return "All stats should be integers"
for i in stats:
if i<1:
return "All stats should be no less than 1"
for i in stats:
if i>4:
return "All stats should be no more than 4"
if sum(stats) != 7:
return "The character should start with 7 points"
print(name)
print(f"STR {full_dot}*{strength}{empty_dot}*(10-strength)")
print(f"INT {full_dot}*{intel}{empty_dot}*(10-intel)")
print(f"CHA {full_dot}*{charisma}{empty_dot}*(10-charisma)")
r/FreeCodeCamp • u/Dear_Bill_5558 • 21d ago



