Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aeabc14
Fix the bug in address.js file
Nov 14, 2025
26642e0
Fix the bug in author.js file
Nov 14, 2025
ab693e3
Fix the bug in recipe.js file
Nov 14, 2025
7105146
Implement a function in contains.js file
Nov 16, 2025
19ca88d
Adding tests in contains.test.js file
Nov 16, 2025
63b7d45
Implementing a function in lookup.js file
Nov 16, 2025
ed3cee8
Adding tests in lookup.test.js file
Nov 16, 2025
1babce8
Fix the implement function in querysrting.js file
Nov 16, 2025
fd422f1
Adding tests in querystring.test.js file
Nov 16, 2025
9279df9
Fix the implement function in tally.js file
Nov 16, 2025
1c6ccc3
Adding tests in tally.test.js file
Nov 16, 2025
8465e56
Answering questions and fix the implemention and adding tests
Nov 16, 2025
81769d1
Adding implementation and test to the file
Nov 24, 2025
d5a5bcd
Answering questions
Nov 24, 2025
f5a92f8
Answering till.js questions
Nov 24, 2025
6d8e6c5
Implementing a alarmclock function
Nov 26, 2025
7221a18
Editing file index.html
Nov 26, 2025
b6b3f4a
Editing file index.html and quotes.js files
Nov 26, 2025
70e0519
Revert "Editing file index.html and quotes.js files"
Fares-Bakhet Dec 1, 2025
5ad1f39
Revert "Editing file index.html"
Fares-Bakhet Dec 1, 2025
413577b
Revert "Implementing a alarmclock function"
Fares-Bakhet Dec 1, 2025
67ecaaa
Revert "Answering till.js questions"
Fares-Bakhet Dec 1, 2025
0939554
Revert "Answering questions"
Fares-Bakhet Dec 1, 2025
0d54919
Revert "Adding implementation and test to the file"
Fares-Bakhet Dec 1, 2025
206b392
Revert "Answering questions and fix the implemention and adding tests"
Fares-Bakhet Dec 1, 2025
75e0482
Revert "Adding tests in tally.test.js file"
Fares-Bakhet Dec 1, 2025
8bb7f6a
Revert "Fix the implement function in tally.js file"
Fares-Bakhet Dec 1, 2025
562022f
Revert "Adding tests in querystring.test.js file"
Fares-Bakhet Dec 1, 2025
62ef964
Revert "Fix the implement function in querysrting.js file"
Fares-Bakhet Dec 1, 2025
5377515
Revert "Adding tests in lookup.test.js file"
Fares-Bakhet Dec 1, 2025
9610268
Revert "Implementing a function in lookup.js file"
Fares-Bakhet Dec 1, 2025
a657abb
Fix quotes generator app
Fares-Bakhet Dec 1, 2025
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
5 changes: 4 additions & 1 deletion Sprint-2/debug/address.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Predict and explain first...
//Prediction: The will be an error at ${address[0]}.
//Explanation: calling an object using the index as in array. Instead we should use the dot method(.address) or the brackets["address"].


// This code should log out the houseNumber from the address object
// but it isn't working...
Expand All @@ -12,4 +15,4 @@ const address = {
postcode: "XYZ 123",
};

console.log(`My house number is ${address[0]}`);
console.log(`My house number is ${address.houseNumber}`);
6 changes: 4 additions & 2 deletions Sprint-2/debug/author.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Predict and explain first...
// Prediction: Going to shows an error in the for loop.
// Explanation: we should have used the for .. in method (The for...in statement iterates over all enumerable string properties of an object (ignoring properties keyed by symbols), including inherited enumerable properties.)

// This program attempts to log out all the property values in the object.
// But it isn't working. Explain why first and then fix the problem
Expand All @@ -11,6 +13,6 @@ const author = {
alive: true,
};

for (const value of author) {
console.log(value);
for (const value in author){
console.log(`${value}: ${author[value]}`);
}
7 changes: 6 additions & 1 deletion Sprint-2/debug/recipe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Predict and explain first...
// Prediction: An error in logging out the ingredients.
// Explanation: Because of the way to get the value or an element from an array should used the dot notation for example and reach each element using its index.

// This program should log out the title, how many it serves and the ingredients.
// Each ingredient should be logged on a new line
Expand All @@ -12,4 +14,7 @@ const recipe = {

console.log(`${recipe.title} serves ${recipe.serves}
ingredients:
${recipe}`);
${recipe.ingredients[0]}
${recipe.ingredients[1]}
${recipe.ingredients[2]}
${recipe.ingredients[3]}`);
8 changes: 7 additions & 1 deletion Sprint-2/implement/contains.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
function contains() {}
function contains(input, propertyName) {
if (input && typeof input === 'object' && !Array.isArray(input)) {
return input.hasOwnProperty(propertyName);
}
return false;

}

module.exports = contains;
46 changes: 45 additions & 1 deletion Sprint-2/implement/contains.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,63 @@ as the object doesn't contains a key of 'c'
// When passed an object and a property name
// Then it should return true if the object contains the property, false otherwise

test("given an object contains a property name, returns true", function (){
const input = {a: 1, b: 2};
const propertyName = 'a';
const currentOutput = contains(input, propertyName);
const targetOutput = true;

expect(currentOutput).toEqual(targetOutput);
});

// Given an empty object
// When passed to contains
// Then it should return false
test.todo("contains on empty object returns false");

test("given an empty object, returns false", function (){
const input = {};
const propertyName = 'a';
const currentOutput = contains(input, propertyName);
const targetOutput = false;

expect(currentOutput).toEqual(targetOutput);
});

// Given an object with properties
// When passed to contains with an existing property name
// Then it should return true

test("given an object contains a property name, returns true", function (){
const input = {a: 1, b: 2};
const propertyName = 'a';
const currentOutput = contains(input, propertyName);
const targetOutput = true;

expect(currentOutput).toEqual(targetOutput);
});

// Given an object with properties
// When passed to contains with a non-existent property name
// Then it should return false

test("given an object does not contain a property name, returns false", function (){
const input = {a: 1, b: 2};
const propertyName = 'c';
const currentOutput = contains(input, propertyName);
const targetOutput = false;

expect(currentOutput).toEqual(targetOutput);
});

// Given invalid parameters like an array
// When passed to contains
// Then it should return false or throw an error

test("given invalid parameters like an array, returns false", function (){
const input = [1, 2, 3];
const propertyName = 'a';
const currentOutput = contains(input, propertyName);
const targetOutput = false;

expect(currentOutput).toEqual(targetOutput);
});
8 changes: 6 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<script defer src="quotes.js"></script>
<title>Quote Generator App</A></title>
</head>
<body>
<main>
<section></section>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</section>
</main>
<script defer src="quotes.js"></script>
</body>
Comment on lines 8 to 18
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Indentation is still off and there seems to be some error in the HTML code.

</html>
16 changes: 16 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
const quoteElem = document.getElementById("quote");
const authorElem = document.getElementById("author");
const button = document.getElementById("new-quote");

function showNewQuote() {
const random = pickFromArray(quotes);
quoteElem.textContent = random.quote;
authorElem.textContent = random.author;
}

window.addEventListener("DOMContentLoaded", () => {
showNewQuote();

button.addEventListener("click", showNewQuote);
});

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down