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
3 changes: 3 additions & 0 deletions Sprint-1/1-key-exercises/1-count.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ count = count + 1;

// Line 1 is a variable declaration, creating the count variable with an initial value of 0
// Describe what line 3 is doing, in particular focus on what = is doing
// Line 3 is updating the value of the count variable by adding 1 to its current value.
// The = operator is an assignment operator that assigns the result of the expression on the right (count + 1)
// back to the variable on the left (count). This effectively increments the count variable by 1 each time this line is executed.
5 changes: 4 additions & 1 deletion Sprint-1/1-key-exercises/2-initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ 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 = ``;


let initials = firstName[0]+ middleName[0] + lastName[0];

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


5 changes: 3 additions & 2 deletions Sprint-1/1-key-exercises/3-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 = ;
const dir = filePath.slice(0, lastSlashIndex);
const ext = filePath.slice(filePath.lastIndexOf(".") + 1);


// https://www.google.com/search?q=slice+mdn
7 changes: 7 additions & 0 deletions Sprint-1/1-key-exercises/4-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
// Try breaking down the expression and using documentation to explain what it means
// It will help to think about the order in which expressions are evaluated
// Try logging the value of num and running the program several times to build an idea of what the program is doing

//Breakdown
// Math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive).
// (maximum - minimum + 1) calculates the range of numbers which is 100 - 1 + 1 = 100.
// Multiplying Math.random() by (maximum - minimum + 1) scales the random decimal to a range of 0 (inclusive) to 100 (exclusive).
// The Math.floor() rounds down the number to the nearest whole number, giving us an integer between 0 and 99.
// Adding minimum (which is 1) shifts the range from 0-99 to 1-100.
5 changes: 4 additions & 1 deletion Sprint-1/2-mandatory-errors/0.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
This is just an instruction for the first activity - but it is just for human consumption
We don't want the computer to run these 2 lines - how can we solve this problem?
We don't want the computer to run these 2 lines - how can we solve this problem?

//This is just an instruction for the first activity - but it is just for human consumption
//We don't want the computer to run these 2 lines - how can we solve this problem?
3 changes: 3 additions & 0 deletions Sprint-1/2-mandatory-errors/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

const age = 33;
age = age + 1;

let age = 33;
age = age + 1;
1 change: 1 addition & 0 deletions Sprint-1/2-mandatory-errors/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
console.log(`I was born in ${cityOfBirth}`);
7 changes: 7 additions & 0 deletions Sprint-1/2-mandatory-errors/3.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ const last4Digits = cardNumber.slice(-4);
// Then run the code and see what error it gives.
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
// Then try updating the expression last4Digits is assigned to, in order to get the correct value

// Prediction: The code won't work because cardNumber is a number, and the slice method is a string method.
// When we try to call slice on a number, it will throw a TypeError because numbers do not have the slice method.
// To fix this, we can convert cardNumber to a string before calling slice on it.

const last4Digits = String(cardNumber).slice(-4);

5 changes: 4 additions & 1 deletion Sprint-1/2-mandatory-errors/4.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const 12HourClockTime = "20:53";
const 24hourClockTime = "08:53";
const 24hourClockTime = "08:53";

const twelveHourClockTime = "20:53";
const twentyFourHourClockTime = "08:53";
20 changes: 20 additions & 0 deletions Sprint-1/3-mandatory-interpret/1-percentage-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,23 @@ console.log(`The percentage change is ${percentageChange}`);
// d) Identify all the lines that are variable declarations

// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?

priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));

// a) there are 5 function calls in this file,// Line 4: replaceAll(",", "") and Number()
// Line 5: replaceAll(",", "") and Number()
// Line 9: console.log()

// b) The error is coming from line 4 and line 5.
// The error occurs because the replaceAll method is being called on a string that contains a comma, which is not a valid number.
// To fix this problem, we can remove the commas from the strings before converting them to numbers.

// c) The variable reassignment statements are on line 4 and line 5, where carPrice and
// priceAfterOneYear are being reassigned to the result of the Number() function.

// d) The variable declarations are on line 1 and line 2, where carPrice and priceAfterOneYear are declared and initialized with string values.

// e) The expression Number(carPrice.replaceAll(",","")) is doing the following:
// 1. This part of the expression takes the string value of carPrice (which is "10,000") and removes all comma, resulting in the string "10000".
// 2. Number(...): This part takes the resulting string "10000" and converts it into a number (10000).

7 changes: 7 additions & 0 deletions Sprint-1/3-mandatory-interpret/2-time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ console.log(result);
// e) What do you think the variable result represents? Can you think of a better name for this variable?

// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer

// a) There are 6 variable declarations in this program: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, and result.
// b) There is 1 function call in this program: console.log(result).
// c) The movieLength % 60 calculates the remainder. This gives us the number of seconds .
// d) The totalMinutes subtracts the extra seconds to get a clean number, then divides by 60 to find the total whole minutes.
// e) The variable result represents the formatted string of hours, minutes, and seconds for the movie length. A better name could be formattedTime.
// f) This code will work for positive integers, but it doesn't add a leading zero to single digits (e.g., it prints 2:5:9 instead of 02:05:09).
17 changes: 15 additions & 2 deletions Sprint-1/3-mandatory-interpret/3-to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,18 @@ console.log(`£${pounds}.${pence}`);
// You need to do a step-by-step breakdown of each line in this program
// Try and describe the purpose / rationale behind each step

// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"

//1. const penceString = "399p": initializes a string variable with the value "399p"

// 2 to 6.const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1);
// removes the (p) at the end determined by removing the sudstring at the total length of the string -1

// 8.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
// makes sure the string is at least 3 characters long and if it is not it padds it with "0"

// 9.const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2);
// gets the ammout of pounds by making a sub string that starts at the firts character (0) to the paddedPenceNumberString length -2 to exclued the last 2 characters (the p)

// 10.
// 18.console.log(`£${pounds}.${pence}`);
// gives the console the result using a string literal
11 changes: 11 additions & 0 deletions Sprint-1/4-stretch-explore/chrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ Now try invoking the function `prompt` with a string input of `"What is your nam

What effect does calling the `prompt` function have?
What is the return value of `prompt`?

//What effect does calling the `alert` function have?
a pop up appered saying hello world

Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`.

What effect does calling the `prompt` function have?
it give a pop up with a text input
What is the return value of `prompt`?
the return is what is entered into the text input if it is blank you will get ''

7 changes: 7 additions & 0 deletions Sprint-1/4-stretch-explore/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ Answer the following questions:

What does `console` store?
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?

//log() { [native code] }Now enter just `console` in the Console, what output do you get back?console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}assert: ƒ assert()clear: ƒ clear()context: ƒ context()count: ƒ count()countReset: ƒ countReset()createTask: ƒ createTask()debug: ƒ debug()dir: ƒ dir()dirxml: ƒ dirxml()error: ƒ error()group: ƒ group()groupCollapsed: ƒ groupCollapsed()groupEnd: ƒ groupEnd()info: ƒ info()log: ƒ log()memory: MemoryInfo {totalJSHeapSize: 12700000, usedJSHeapSize: 10000000, jsHeapSizeLimit: 2330000000}profile: ƒ profile()profileEnd: ƒ profileEnd()table: ƒ table()time: ƒ time()timeEnd: ƒ timeEnd()timeLog: ƒ timeLog()timeStamp: ƒ timeStamp()trace: ƒ trace()warn: ƒ warn()length: 0name: "warn"arguments: (...)caller: (...)[[Prototype]]: ƒ ()[[Scopes]]: Scopes[0]Symbol(Symbol.toStringTag): "console"[[Prototype]]: Object[[Prototype]]: Object
Try also entering `typeof console`'object'
Answer the following questions:What does `console` store?the console stores objects
What does the syntax `console.log` or `console.assert` mean?
In particular, what does the `.` mean?
the . denotes what kind of object the console is being told to use and what to do with the data it has been given