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
5 changes: 4 additions & 1 deletion .questions/questions-0/index.md
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 1 addition & 1 deletion .questions/questions-1/index.md
Original file line number Diff line number Diff line change
@@ -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!
2 changes: 1 addition & 1 deletion .questions/questions-2/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
2 changes: 1 addition & 1 deletion .questions/questions-3/index.md
Original file line number Diff line number Diff line change
@@ -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!
4 changes: 3 additions & 1 deletion .questions/questions-4/index.md
Original file line number Diff line number Diff line change
@@ -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!
17 changes: 14 additions & 3 deletions dom-merge-conflict/tasks/buttons-and-counter/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@ 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 = `
<h1>Number Counter</h1>
<p>A simple counter. Press increment to increase the count by one.</p>
<p>
A simple counter. Press decrement to decrease the count by one.
A simple counter. Press increment to increase the count by one.
</p>

`;
body.appendChild(header);

const main = document.createElement("main");
main.innerHTML = `
<p id="counter" data-testid="counter">0</p>
<button id="increment">Increment</button>
<button id="decrement">Decrement</button>
`;
body.appendChild(main);

Expand All @@ -26,6 +34,9 @@ export function App() {
button.addEventListener("click", () => {
increment(counter);
});

const decButton = body.querySelector("#decrement");
button.addEventListener("click", () => {
decrement(counter);
})
return body;
}
12 changes: 5 additions & 7 deletions dom-merge-conflict/tasks/buttons-and-counter/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
5 changes: 3 additions & 2 deletions questions-and-reviews/questions/0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion questions-and-reviews/questions/1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 8 additions & 2 deletions questions-and-reviews/questions/2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Runs Perfectly so it the count keeps adding 1 until it gets to ten using the asterisk
*
**
***
****
*****
until it get to ten
3 changes: 2 additions & 1 deletion questions-and-reviews/questions/4.md
Original file line number Diff line number Diff line change
@@ -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!