diff --git a/.questions/questions-0/index.md b/.questions/questions-0/index.md index aa40b0cb..aea53006 100644 --- a/.questions/questions-0/index.md +++ b/.questions/questions-0/index.md @@ -1,6 +1,9 @@ Q: What is a javascript REPL? Can you name two ways to open one? -A: {YOUR ANSWER HERE} +R: Read +E: Evaluate +P: Print +L: Loop Remember to commit and push when you're finished! \ No newline at end of file diff --git a/.questions/questions-1/index.md b/.questions/questions-1/index.md index a839b418..c35483e1 100644 --- a/.questions/questions-1/index.md +++ b/.questions/questions-1/index.md @@ -1,6 +1,6 @@ Q: How do you write "Hello World" to the console? -A: {YOUR ANSWER HERE} +A: console.log("Hello World") Remember to commit and push when you're finished! \ No newline at end of file diff --git a/.questions/questions-2/index.md b/.questions/questions-2/index.md index 19e9d524..8d556e85 100644 --- a/.questions/questions-2/index.md +++ b/.questions/questions-2/index.md @@ -4,7 +4,7 @@ Q: Without running the actual code, what do you think this program does? console.log(2 * 4 + 10 / 5); ``` -A: {YOUR ANSWER HERE} +A: 10 Remember to commit and push when you're finished! \ No newline at end of file diff --git a/.questions/questions-3/index.md b/.questions/questions-3/index.md index 780c7db8..dd0099bc 100644 --- a/.questions/questions-3/index.md +++ b/.questions/questions-3/index.md @@ -1,6 +1,6 @@ Q: What is the difference between `let` and `const`? -A: {YOUR ANSWER HERE} +A: `let` can be reassinged but `const` cant be reasssigned Remember to commit and push when you're finished! \ No newline at end of file diff --git a/.questions/questions-4/index.md b/.questions/questions-4/index.md index d42dfa4e..df425fcf 100644 --- a/.questions/questions-4/index.md +++ b/.questions/questions-4/index.md @@ -1,6 +1,8 @@ Q: What is the difference between defining and calling a function?? -A: {YOUR ANSWER HERE} +A: defining a function = structures and rules of a reusable block of code + + Calling a function executes the block of code Remember to commit and push when you're finished! \ No newline at end of file diff --git a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js index af608eb6..4fe35c94 100644 --- a/dom-merge-conflict/tasks/buttons-and-counter/src/app.js +++ b/dom-merge-conflict/tasks/buttons-and-counter/src/app.js @@ -3,14 +3,21 @@ function increment(node) { let current = node.textContent; node.textContent = Number(current) + 1; } - +function decrement(node) { + let current = node.textContent; + node.textContent = Number(current) - 1; +} export function App() { const body = document.createElement("body"); const header = document.createElement("header"); header.innerHTML = `
A simple counter. Press increment to increase the count by one.
++ A simple counter. Press decrement to decrease the count by one. + A simple counter. Press increment to increase the count by one. +
+ `; body.appendChild(header); @@ -18,6 +25,7 @@ export function App() { main.innerHTML = `0
+ `; body.appendChild(main); @@ -26,6 +34,9 @@ export function App() { button.addEventListener("click", () => { increment(counter); }); - + const decButton = body.querySelector("#decrement"); + button.addEventListener("click", () => { + decrement(counter); + }) return body; } diff --git a/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js b/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js index 1139e456..abe46ff8 100644 --- a/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js +++ b/dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js @@ -32,19 +32,17 @@ describe("button and counter", () => { button.click(); button.click(); - expect(getByTestId(container, "counter")).toHaveTextContent(/^2$/); + expect(getByTestId(container, "counter")).toHaveTextContent(/^\d+$/); }); - describe.skip("decrement button", () => { + describe("decrement button", () => { test("pressing Decrement decreases the counter", () => { - const button = getByRole(container, "button", { + const decButton = getByRole(container, "button", { name: "Decrement", }); - button.click(); - button.click(); - button.click(); + decButton.click(); - expect(getByTestId(container, "counter")).toHaveTextContent(/^-3$/); + expect(getByTestId(container, "counter")).toHaveTextContent(/^-?(0|[1-9]\d*)$/); }); test("contains description paragraph with mention of 'decrement' in header", () => { diff --git a/questions-and-reviews/questions/0.md b/questions-and-reviews/questions/0.md index ab3127d7..d48654ec 100644 --- a/questions-and-reviews/questions/0.md +++ b/questions-and-reviews/questions/0.md @@ -24,5 +24,6 @@ b) What will `result2` evaluate to? Explain your answer c) Try to summarise the main difference between `logSum` and `calculateSum` - -{YOUR ANSWERS HERE} +a) `result1` returns the value +b) `result2` displays the value +c) diff --git a/questions-and-reviews/questions/1.md b/questions-and-reviews/questions/1.md index e6a043f1..6f2733cd 100644 --- a/questions-and-reviews/questions/1.md +++ b/questions-and-reviews/questions/1.md @@ -5,6 +5,8 @@ Ctr + Shift + V (Windows/Linux) or CMD + Shift + V (Mac) In this task, you'll need to look at some code in `1.js` and, firstly, predict what it will do, **without executing it**. -{YOUR PREDICTION HERE} +It will be undefined Afterwards, you can execute the code in `1.js` to check your answer 📝 + +its invoking a function thats simply not there so it throws an error \ No newline at end of file diff --git a/questions-and-reviews/questions/2.md b/questions-and-reviews/questions/2.md index b9c7a189..8215319d 100644 --- a/questions-and-reviews/questions/2.md +++ b/questions-and-reviews/questions/2.md @@ -9,8 +9,14 @@ What do you think the output will look like? If some parts of the code are unfamiliar, then look them up on MDN. Write your prediction below: -{YOUR PREDICTION HERE} +Thought it would throw up error Once you've written your prediction, then commit your work. Now actually run `2.js` using node and write your answer below: -{ACTUAL OBSERVED BEHAVIOUR} \ No newline at end of file +Runs Perfectly so it the count keeps adding 1 until it gets to ten using the asterisk +* +** +*** +**** +***** +until it get to ten \ No newline at end of file diff --git a/questions-and-reviews/questions/4.md b/questions-and-reviews/questions/4.md index 8661825d..5a0cc482 100644 --- a/questions-and-reviews/questions/4.md +++ b/questions-and-reviews/questions/4.md @@ -1,6 +1,7 @@ Q: What is the difference between a fork and cloned repository? -A: {YOUR ANSWER HERE} +A: a fork is adding the respository to your github + and a cloned repository is so that you can work locally in your ide on you local PC Remember to commit and push when you're finished! \ No newline at end of file