Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"ritwickdey.LiveServer",
"vsliveshare.vsliveshare"
"vsliveshare.vsliveshare",
"Orta.vscode-jest"
]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ let lastName = "Johnson";

// Declare a variable called initials that stores the first character of each string.
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.

let initials = ``;

// https://www.google.com/search?q=get+first+character+of+string+mdn

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ console.log(`The base part of ${filePath} is ${base}`);

// Create a variable to store the dir part of the filePath variable
// Create a variable to store the ext part of the variable

const dir = ;
const ext = ;

// https://www.google.com/search?q=slice+mdn
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ console.log(result);
// b) How many function calls are there?

// c) Using documentation, explain what the expression movieLength % 60 represents
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?

Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions Sprint-1/exercises/decimal.js

This file was deleted.

24 changes: 19 additions & 5 deletions Sprint-1/readme.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
# 🧭 Guide to Week 1 exercises

> https://programming.codeyourfuture.io/structuring-data/sprints/1/prep/

> [!TIP]
> You should always do the prep work _before_ attempting the coursework.
> The prep shows you _how_ to do the coursework.
> There is often a step by step video you can code along with too.
> Do the prep.

This README will guide you through the different sections for this week.

## Exercises
## 1 Exercises

In this section, you'll have a short program and task. Some of the syntax may be unfamiliar - in this case, you'll need to look things up in documentation.

In this section, you'll have a short program and task. Some of the syntax may be unfamiliar - in this case, you'll need to look things up in documentation.
https://developer.mozilla.org/en-US/docs/Web/JavaScript

## Errors
## 2 Errors

In this section, you'll need to go to each file in `errors` directory and run the file with node to check what the error is. Your task is to interpret the error message and explain why it occurs. The [errors documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors) will help you figure out the solution.

## Interpret
## 3 Interpret

In these tasks, you have to interpret a slightly larger program with some syntax / operators / functions that may be unfamiliar.

You must use documentation to make sense of anything unfamiliar - learning how to look things up this way is a fundamental part of being a developer!

You can also use `console.log` to check the value of different variables in the code.

## Explore - Stretch 💪
https://developer.mozilla.org/en-US/docs/Web/JavaScript

## 4 Explore - Stretch 💪

This stretch activity will get you to start exploring new concepts and environments by yourself. It will do so by prompting you to reflect on some questions.
4 changes: 4 additions & 0 deletions Sprint-2/errors/0.js → Sprint-2/1-key-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Predict and explain first...
// =============> write your prediction here

// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
Expand All @@ -7,3 +8,6 @@ function capitalise(str) {
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
return str;
}

// =============> write your explanation here
// =============> write your new code here
7 changes: 7 additions & 0 deletions Sprint-2/errors/1.js → Sprint-2/1-key-errors/1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Predict and explain first...

// Why will an error occur when this program runs?
// =============> write your prediction here

// Try playing computer with the example to work out what is going on

function convertToPercentage(decimalNumber) {
Expand All @@ -11,3 +13,8 @@ function convertToPercentage(decimalNumber) {
}

console.log(decimalNumber);

// =============> write your explanation here

// Finally, correct the code to fix the problem
// =============> write your new code here
20 changes: 20 additions & 0 deletions Sprint-2/1-key-errors/2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

// Predict and explain first BEFORE you run any code...

// this function should square any number but instead we're going to get an error

// =============> write your prediction of the error here

function square(3) {
return num * num;
}

// =============> write the error message here

// =============> explain this error message here

// Finally, correct the code to fix the problem

// =============> write your new code here


14 changes: 14 additions & 0 deletions Sprint-2/2-mandatory-debug/0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Predict and explain first...

// =============> write your prediction here

function multiply(a, b) {
console.log(a * b);
}

console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

// =============> write your explanation here

// Finally, correct the code to fix the problem
// =============> write your new code here
13 changes: 13 additions & 0 deletions Sprint-2/2-mandatory-debug/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Predict and explain first...
// =============> write your prediction here

function sum(a, b) {
return;
a + b;
}

console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

// =============> write your explanation here
// Finally, correct the code to fix the problem
// =============> write your new code here
10 changes: 10 additions & 0 deletions Sprint-2/debug/2.js → Sprint-2/2-mandatory-debug/2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Predict and explain first...

// Predict the output of the following code:
// =============> Write your prediction here

const num = 103;

function getLastDigit() {
Expand All @@ -10,5 +13,12 @@ console.log(`The last digit of 42 is ${getLastDigit(42)}`);
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
console.log(`The last digit of 806 is ${getLastDigit(806)}`);

// Now run the code and compare the output to your prediction
// =============> write the output here
// Explain why the output is the way it is
// =============> write your explanation here
// Finally, correct the code to fix the problem
// =============> write your new code here

// This program should tell the user the last digit of each number.
// Explain why getLastDigit is not working properly - correct the problem
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
// Given someone's weight in kg and height in metres
// Then when we call this function with the weight and height
// It should return their Body Mass Index to 1 decimal place

function calculateBMI(weight, height) {
// return the BMI of someone based off their weight and height
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
// Another example: "lord of the rings" should be "LORD_OF_THE_RINGS"

// You will need to come up with an appropriate name for the function
// Use the string documentation to help you find a solution
// Use the MDN string documentation to help you find a solution
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ function formatTimeDisplay(seconds) {
const remainingMinutes = totalMinutes % 60;
const totalHours = (totalMinutes - remainingMinutes) / 60;

return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(
remainingSeconds
)}`;
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
}

// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
Expand All @@ -19,13 +17,18 @@ function formatTimeDisplay(seconds) {
// Questions

// a) When formatTimeDisplay is called how many times will pad be called?
// =============> write your answer here

// Call formatTimeDisplay with an input of 61, now answer the following:

// b) What is the value assigned to num when pad is called for the first time?
// =============> write your answer here

// c) What is the return value of pad is called for the first time?
// =============> write your answer here

// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
// =============> write your answer here

// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
// =============> write your answer here
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// This is the latest solution to the problem from the prep.
// Make sure to do the prep before you do the coursework
// Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find.

function formatAs12HourClock(time) {
Expand Down
7 changes: 0 additions & 7 deletions Sprint-2/debug/0.js

This file was deleted.

8 changes: 0 additions & 8 deletions Sprint-2/debug/1.js

This file was deleted.

10 changes: 0 additions & 10 deletions Sprint-2/errors/2.js

This file was deleted.

10 changes: 0 additions & 10 deletions Sprint-2/implement/vat.js

This file was deleted.

31 changes: 21 additions & 10 deletions Sprint-2/readme.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
# 🧭 Guide to week 2 exercises

## Errors
> https://programming.codeyourfuture.io/structuring-data/sprints/2/prep/

> [!TIP]
> You should always do the prep work _before_ attempting the coursework.
> The prep shows you how to do the coursework.
> There is often a step by step video you can code along with too.
> Do the prep.

## 1 Errors

In this section, you need to go to each file in `errors` directory. Read the file and predict what error will happen. Then run the file with node to check what the error is. Your task is to interpret the error message and explain why it occurs. The [errors documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors) will help you figure out the solution.

## Debug
## 2 Debug

In this section, you need to go to each file in `debug` to **explain and predict** why the program isn't behaving as intended. Then you'll need to run the program with node to check your prediction. You will also need to correct the code too.

## Implement
## 3 Implement

In this section, you will have a short set of requirements about a function. You will need to implement a function based off this set of requirements. Make sure you check your function works for a number of different inputs.

Here is a recommended order:

1. `to-pounds.js`
2. `vat.js`
3. `cases.js`
4. `bmi.js`
1. `1-bmi.js`
1. `2-cases.js`
1. `3-to-pounds.js`

## Interpret
## 4 Interpret

In these tasks, you have to interpret a slightly larger program with some syntax / operators / functions that may be unfamiliar.

You must use documentation to make sense of anything unfamiliar. Learning how to look things up this way is a fundamental part of being a developer!

You can also use `console.log` to check the value of different variables in the code.

## Extend
## 5 Extend

In the prep for this sprint, we developed a function to convert 24 hour clock times to 12 hour clock times.
Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find.

Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find. This section is not mandatory, but it will also help you solve some similar kata in Codewars.
56 changes: 56 additions & 0 deletions Sprint-3/1-key-implement/1-get-angle-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Implement a function getAngleType
// Build up your function case by case, writing tests as you go
// The first test and case is written for you. The next case has a test, but no code.
// Execute this script in your terminal
// node 1-get-angle-type.js
// The assertion error will tell you what the expected output is
// Write the code to pass the test
// Then, write the next test! :) Go through this process until all the cases are implemented

function getAngleType(angle) {
if (angle === 90) return "Right angle";
// read to the end, complete line 36, then pass your test here
}

// we're going to use this helper function to make our assertions easier to read
// if the actual output matches the target output, the test will pass
function assertEquals(actualOutput, targetOutput) {
console.assert(
actualOutput === targetOutput,
`Expected ${actualOutput} to equal ${targetOutput}`
);
}

// Acceptance criteria:

// Given an angle in degrees,
// When the function getAngleType is called with this angle,
// Then it should:

// Case 1: Identify Right Angles:
// When the angle is exactly 90 degrees,
// Then the function should return "Right angle"
const right = getAngleType(90);
assertEquals(right, "Right angle");

// Case 2: Identify Acute Angles:
// When the angle is less than 90 degrees,
// Then the function should return "Acute angle"
const acute = getAngleType(45);
assertEquals(acute, "Acute angle");

// Case 3: Identify Obtuse Angles:
// When the angle is greater than 90 degrees and less than 180 degrees,
// Then the function should return "Obtuse angle"
const obtuse = getAngleType(120);
// ====> write your test here, and then add a line to pass the test in the function above

// Case 4: Identify Straight Angles:
// When the angle is exactly 180 degrees,
// Then the function should return "Straight angle"
// ====> write your test here, and then add a line to pass the test in the function above

// Case 5: Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"
// ====> write your test here, and then add a line to pass the test in the function above
Loading