Learn Basic JavaScript by Building a Role Playing Game - Step 152
The freeCodeCamp Forum » JavaScript
by devuktm966
2h ago
Tell us what’s happening: What is to be the if condition that has to be provided Your code so far <!-- file: index.html --> /* file: styles.css */ /* file: script.js */ // User Editable Region function attack() { text.innerText = "The " + monsters[fighting].name + " attacks."; text.innerText += " You attack it with your " + weapons[currentWeapon].name + "."; health -= getMonsterAttackValue(monsters[fighting].level); if (health < 0) { isMonsterHit(); // Call the isMonsterHit function } monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random ..read more
Visit website
Learn Basic JavaScript by Building a Role Playing Game - Step 27
The freeCodeCamp Forum » JavaScript
by RichardAwesome
3h ago
Tell us what’s happening: Why didn’t they use #text for the max height and width Your code so far <!-- file: index.html --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link href="./styles.css"> <title>RPG - Dragon Repeller</title> </head> <body> <div id="game"> <div id="stats"> <span >XP: <strong><span id="xpText">0</span></strong></span> <span >Health: <strong><span id="healthText">100</span></s ..read more
Visit website
Basic javascript step 81
The freeCodeCamp Forum » JavaScript
by magdalinemumbi573
3h ago
Im trying to include the if statement condition to this code: function buyHealth() { if (gold >= 10) { health += 10; goldText.innerText = gold; healthText.innerText = health; } else { console.log("not enough gold"); } } but im getting this error: All of your buyHealth code should be inside the if statement. . What is wrong with my code. kindly assist. 4 posts - 3 participants Read full topic ..read more
Visit website
Learn Intermediate OOP by Building a Platformer Game - Step 31
The freeCodeCamp Forum » JavaScript
by tevirungu
5h ago
Tell us what’s happening: My condition should check if the player’s x position is less than the width and I tried checking both “this.position.x & this.width”. Where have I made an error please? Your code so far <!-- file: index.html --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Learn Intermediate OOP by Building a Platformer Game</title> <link href="./s ..read more
Visit website
Learn Regular Expressions by Building a Spam Filter - Step 2
The freeCodeCamp Forum » JavaScript
by donLamarr
7h ago
Tell us what’s happening: I cannot get past this test it keeps saying method should have an empty callback function but it appears to be that it is already empty Your code so far <!-- file: index.html --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width" /> <title>Learn Regular Expressions by Building a Spam Filter</title> <link href="styles.css" /> </head> <body> <header > <h1 >Is this Spam?</h1> <p &g ..read more
Visit website
Role Playing Game Step 174
The freeCodeCamp Forum » JavaScript
by tallgirlsfinishlast
7h ago
Here is the full question: " Inside your for loop, use the += operator to add to the end of text.innerText. Add the number at index i of the numbers array, using numbers[i]. Then add a new line, using the escape sequence you used earlier." Here is my code: function pick(guess) { const numbers = []; while (numbers.length < 10) { numbers.push(Math.floor(Math.random() * 11)); } text.innerText = "You picked " + guess + ". Here are the random numbers:\n"; for (let i = 0; i < 10; i++) { text.innerText += numbers[i]\n; } } When I followed the same syntax above when doing a new ..read more
Visit website
JavaScript Algorithms and Data Structures (Beta)
The freeCodeCamp Forum » JavaScript
by TenshiCoding
8h ago
Hey I’m having an issue with my validation logic. My function is correctly identifying incorrect US numbers but incorrectly identifying the valid ones (reading them as invalid). I’ve tried adjusting whitespaces, making them optional and playing around with the hyphens. Am i missing an anchor or? function validator() { const inputValue = input.value.trim(); if (inputValue === “”) { alert(“Please provide a phone number”); return; } const countryCode = /^(1|+1)?\s*?/; const areaCode = /^((\d{3}))?\s*?\d{3}/; const mainNumber = /\s*?-?\s*?\d{3}-?\s*?\d{4}/; const phoneRegex = new RegExp(${countryC ..read more
Visit website
Learn Form Validation by Building a Calorie Counter - Step 41
The freeCodeCamp Forum » JavaScript
by j.virg
10h ago
Tell us what’s happening: I am on Step 41 of Learn Form Validation by Building a Calorie Counter. The website preview has stopped showing for some reason and I’m getting this error under the “check your code” box. Another forum had the same code and was correct? SyntaxError: unknown: Unexpected token, expected “,” (21:55) 19 | function addEntry() { 20 | const targetId = “#” + entryDropdown.value; > 21 | const targetInputContainer = document.querySelector(${targetId} .input-container); | ^ 22 | } Your code so far /* file: script.js */ // User Editable Region function addEntry() { const t ..read more
Visit website
Learn Asynchronous Programming by Building an fCC Forum Leaderboard - Step 16
The freeCodeCamp Forum » JavaScript
by azongo
13h ago
Tell us what’s happening: want to return an empty table row (tr) using template literals in JavaScript. How do I do it? Your code so far <!-- file: index.html --> /* file: styles.css */ /* file: script.js */ // User Editable Region postsContainer.innerHTML = topics.map((item) => { const { id, title, views, posts_count, slug, posters, category_id, bumped_at, } = item; return` <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> ..read more
Visit website
Learn Intermediate OOP by Building a Platformer Game - Step 91
The freeCodeCamp Forum » JavaScript
by saraunic24
13h ago
Tell us what’s happening: if (platformDetectionRules.every(rule => true)); not understanding what’s wrong Your code so far <!-- file: index.html --> /* file: styles.css */ /* file: script.js */ // User Editable Region if (platformDetectionRules.every(rule => true)) // User Editable Region Your browser information: User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.15 Challenge Information: Learn Intermediate OOP by Building a Platformer Game - Step 91 freecodecamp.org freeCodeCamp.org Learn ..read more
Visit website

Follow The freeCodeCamp Forum » JavaScript on FeedSpot

Continue with Google
Continue with Apple
OR