Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sprint-3/3-dead-code/exercise-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ let testName = "Jerry";
const greeting = "hello";

function sayHello(greeting, name) {
const greetingStr = greeting + ", " + name + "!";

return `${greeting}, ${name}!`;
console.log(greetingStr);

}

testName = "Aman";
Expand Down
5 changes: 0 additions & 5 deletions Sprint-3/3-dead-code/exercise-2.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will throw an error when run. Can you spot why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the code and it hasn't thrown an error. I only deleted parts that were unnecessary in the code, its still running ok and giving me an output. Should I return the original code?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you send me the output you are getting when running Sprint-3/3-dead-code/exercise-2.js?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkavalikas Apologies for the late reply, completely forgot I hadn't sent a reply. I'm getting Hamster 3, Horse 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Maryanne-K , that's absolutely fine. Can you do me a favour and add the contents of your file to the browser console (F12 -> Console tab) and let me know if you are getting the same results?

The version committed on git is missing something that should throw errors for all IDEs and runtime environments, so unless you have a different version of your code locally, I'm confused as to how it would work for you 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why its working but I went through the code again and made changes to it, I added back the following:

const petsStartingWithH = pets.filter((pet) => pet[0] === "h");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you for sending it over! Do you see the blue arrow on the first line // Remove ... ? That means the code was indeed pasted, but you haven't run it yet. The grey "results" you see towards the end are the comments added in the code // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log . While you are on that screen, can you press "Enter", run these lines and copy over what you see?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, that was the part that was missing! Before we mark this PR as completed, can I ask you to run the code on the console and send a screenshot of that? You can either run the code that would throw the error or your new one; either of them will work!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I see the issue now, petsStartingWithH wasn't defined. I've defined it and updated the code. Thank you!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkavalikas Please see the screenshot of the corrected code.

Screenshot 2026-03-09 at 16 24 43

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
// The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable.

const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
const capitalisedPets = pets.map((pet) => pet.toUpperCase());
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");

function logPets(petsArr) {
petsArr.forEach((pet) => console.log(pet));
}

function countAndCapitalisePets(petsArr) {
const petCount = {};

Expand Down