Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Closed
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
4 changes: 3 additions & 1 deletion exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
console.log("Hello world");
console.log("Hello world I am relearning Javascript :)");
console.log(7);
console.log("this is another log");
4 changes: 3 additions & 1 deletion exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Start by creating a variable `greeting`

var greeting = "Hello Tersia how are you today?"
console.log(greeting);
console.log(greeting);
console.log(greeting);
3 changes: 3 additions & 0 deletions exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `message`
var message = "This is a string";
var messageType = typeof message;

console.log(message);
console.log(messageType);
8 changes: 7 additions & 1 deletion exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Start by creating a variable `message`
var greetingStart = "Hello, my name is ";
var names = "Tersia";

var greeting = greetingStart + names ;

console.log(greeting);


console.log(message);
16 changes: 15 additions & 1 deletion exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Start by creating a variable `message`
var greetingStart = "Hello, my name is ";
var names = "Daniel and my name is";

console.log(message);
var greeting = greetingStart + names ;

var names = "Daniel";
var nameLength = names.length;

var nameLen = " characters long"

var fullGreeting = greetingStart + names + nameLength + nameLen

console.log(greeting);
console.log(nameLength);
console.log(fullGreeting);
// My name is Daniel and my name is 6 characters long
18 changes: 16 additions & 2 deletions exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
const name = " Daniel ";
var greetingStart = "Hello, my name is ";
var names = "Tersia and my name is";

var greeting = greetingStart + names ;

var names = "Tersia ";
var nameLength = names.length;

var nameLen = " characters long."

var fullGreeting = greetingStart + names + nameLength + nameLen

// console.log(greeting);
// console.log(nameLength);
console.log(fullGreeting.trim());


console.log(message);
11 changes: 11 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
var studentNum = "Number of students: "
var mentorsNum = "Number of mentors: "
var people = "Total number of students and mentors:"

var students = 15;
var mentors = 8;
var total = 15 + 8;

console.log(studentNum + students);
console.log(mentorsNum + mentors);
console.log(people + total);
13 changes: 13 additions & 0 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
var percentage = numberOfStudents + numberOfMentors;

let percentageOfStudents = `Percentage students: ${numberOfStudents / percentage * 100} `;
let percentageOfMentors = `Percentage mentors: ${numberOfMentors / percentage * 100}`;

let students = 65.21739130434783
let studentpercent = Math.round(students)
let mentors = 34.78260869565217
let mentorspercent = Math.round(mentors)


console.log(studentpercent);
console.log(mentorspercent);
1 change: 1 addition & 0 deletions exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function halve(number) {
// complete the function here
return number / 2
}

var result = halve(12);
Expand Down
1 change: 1 addition & 0 deletions exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function triple(number) {
// complete function here
return number * 3
}

var result = triple(12);
Expand Down
1 change: 1 addition & 0 deletions exercises/K-functions-parameters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Hello, my name is Daniel

## Expected result


```
Hello, my name is Daniel and I'm 30 years old
```
4 changes: 3 additions & 1 deletion exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Complete the function so that it takes input parameters
function multiply() {
function multiply(dig, num) {
// Calculate the result of the function and return it
return dig * num;
}


// Assign the result of calling the function the variable `result`
var result = multiply(3, 4);

Expand Down
4 changes: 3 additions & 1 deletion exercises/K-functions-parameters/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Declare your function first

function divide (num1, num2){
return num1 / num2
}
var result = divide(3, 4);

console.log(result);
7 changes: 6 additions & 1 deletion exercises/K-functions-parameters/exercise3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Write your function here

var greeting = createGreeting("Daniel");
var greeting = "Hello my name is, Daniel"

function createGreeting(){
return greeting ;
}


console.log(greeting);
5 changes: 4 additions & 1 deletion exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Declare your function first

function addnumbers (numberone, numbertwo){
return numberone + numbertwo
}
// Call the function and assign to a variable `sum`
var sum = addnumbers(13, 124);

console.log(sum);
7 changes: 6 additions & 1 deletion exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Declare your function here
const string = "Hello, my name is Daniel and I'm ";
const stringtwo = " years old";

const greeting = createLongGreeting("Daniel", 30);
function introduction(age){
return string + age + stringtwo;
}
const greeting = introduction(30);

console.log(greeting);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tersia, your const greeting contains two functions, one is createLongGreeting() and the other one is Introduction() so I wonder what would happen when invoking 2 functions under one variable, please review this situation.

1 change: 1 addition & 0 deletions exercises/L-functions-nested/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Functions are very powerful.
- You can use variables inside of functions.
- You can call other functions inside of functions!


```js
function getAgeInDays(age) {
return age * 365;
Expand Down
14 changes: 14 additions & 0 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,17 @@ var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

let name1 = mentor1.toUpperCase();
let name2 = mentor2.toUpperCase();
let name3 = mentor3.toUpperCase();
let name4 = mentor4.toUpperCase();
let name5 = mentor5.toUpperCase();

function shouty(){
let test = {hi: name1, hi: name2, name3, name4, name5}
return test
}

let test1 = shouty()
console.log(test1.name3);
15 changes: 9 additions & 6 deletions mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// There are syntax errors in this code - can you fix it to pass the tests?

function addNumbers(a b c) {

function addNumbers(a, b, c) {
return a + b + c;
}

function introduceMe(name, age)
return "Hello, my name is " + name "and I am " age + "years old";
function introduceMe(name, age){
return "Hello, my name is " + name + " and I am " + age + " years old";
}

function getTotal(a, b) {
total = a ++ b;
function getTotal(a, b){
var total = a + b;

return "The total is total";
return "The total is " + total;
}


/*
===================================================
======= TESTS - DO NOT MODIFY BELOW THIS LINE =====
Expand Down
8 changes: 4 additions & 4 deletions mandatory/2-logic-error.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// The syntax for this function is valid but it has an error, find it and fix it.

function trimWord(word) {
return wordtrim();
return word.trim();
}

function getStringLength(word) {
return "word".length();
return word.length;
}

function multiply(a, b, c) {
a * b * c;
return;
return a * b * c;

}

/*
Expand Down
5 changes: 5 additions & 0 deletions mandatory/3-function-output.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
// Add comments to explain what this function does. You're meant to use Google!
// method to create a function that will return a random integer between 0 and 9 values

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not only returns the integer but any number between 0 and 10, that number can sometimes be 9.99

function getRandomNumber() {
return Math.random() * 10;
}


// Add comments to explain what this function does. You're meant to use Google!
// This function concatenates two strings together
function combine2Words(word1, word2) {
return word1.concat(word2);
}

function concatenate(firstWord, secondWord, thirdWord) {
// Write the body of this function to concatenate three words together.
// Look at the test case below to understand what this function is expected to return.

return firstWord.concat("", secondWord ," ",thirdWord)
}

/*
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@
"url": "https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1/issues"
},
"jest": {
"setupFilesAfterEnv": ["jest-extended"],
"setupFilesAfterEnv": [
"jest-extended"
],
"projects": [
{
"displayName": "mandatory",
"testMatch": ["<rootDir>/mandatory/*.js"]
"testMatch": [
"<rootDir>/mandatory/*.js"
]
},
{
"displayName": "extra",
"testMatch": ["<rootDir>/extra/*.js"]
"testMatch": [
"<rootDir>/extra/*.js"
]
}
]
},
Expand Down