Skip to content
This repository was archived by the owner on Oct 26, 2020. It is now read-only.

Java script core 1 homework/week3/osagie #91

Open
wants to merge 85 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
7178a43
first JS practice
osagiestar Jun 15, 2020
e0e8ecb
first JS practice
osagiestar Jun 15, 2020
81ce14a
a change made
osagiestar Jun 15, 2020
e4ed185
F-strings exercise
osagiestar Jun 15, 2020
c376b43
G-numbers exercise
osagiestar Jun 15, 2020
a05a8b9
I-floatss exercise
osagiestar Jun 16, 2020
cd4d589
I-floats exercise
osagiestar Jun 16, 2020
e6a356a
J-functionss exercise
osagiestar Jun 16, 2020
38a4447
J-functions exercise2
osagiestar Jun 16, 2020
be3ab99
K-functions exercise1
osagiestar Jun 16, 2020
88ce31d
K-functions exercise2 answer no1
osagiestar Jun 16, 2020
fc834ac
K-functions 1-exercise// Complete the function so that it takes input…
osagiestar Jun 16, 2020
38eef0b
K-functions 1-exercise Exercise 3
osagiestar Jun 16, 2020
d31a191
syntax debugging
osagiestar Jun 17, 2020
06e8051
parenthesis for trim; none for length
osagiestar Jun 17, 2020
af4b3a6
function outputs for concatenate
osagiestar Jun 18, 2020
5135f7f
learnt to use toFixed function for adding float to integers
osagiestar Jun 19, 2020
4b5169e
learnt techniques for concatenation
osagiestar Jun 19, 2020
3da6d6d
learnt techniques for concatenation of strings i.e joining strings to…
osagiestar Jun 19, 2020
bfd8e60
test the console.log() syntax
osagiestar Jun 19, 2020
78141c0
test the console.log() syntax
osagiestar Jun 19, 2020
ee7a874
create variable aand output result
osagiestar Jun 19, 2020
355834f
learnt how to use (typeof) syntax
osagiestar Jun 19, 2020
08eee6f
use of + sign to join strings
osagiestar Jun 19, 2020
86dfcb8
learnt the trim() syntax
osagiestar Jun 19, 2020
0857676
implemented trim() syntax
osagiestar Jun 19, 2020
b949687
use of Math.round to convert floats/decimal numbers to whole integers
osagiestar Jun 19, 2020
b4fd296
calling a function
osagiestar Jun 19, 2020
cc4aa98
declare a function first and then call the function using console.log()
osagiestar Jun 20, 2020
525d696
more work to be done
osagiestar Jun 20, 2020
c68d50f
learnt function in a function method
osagiestar Jun 20, 2020
4083bf9
setting boolean conditions
osagiestar Jun 22, 2020
de1c5a9
used comparison operators
osagiestar Jun 22, 2020
c2bc5cb
using true or false rules
osagiestar Jun 22, 2020
2a27ae3
setting condition for console.log match reuslt
osagiestar Jun 22, 2020
0bb140c
used array
osagiestar Jun 23, 2020
5c5edc3
AND and OR logic
osagiestar Jun 23, 2020
5aac1a9
passed first task, the rest to be continued...
osagiestar Jun 23, 2020
5ced16b
added omitted sign > and value 5
osagiestar Jun 24, 2020
86c0047
logical operator application
osagiestar Jun 24, 2020
c0527cc
returns a string values
osagiestar Jun 24, 2020
cd61d5a
takes numbers and return string values
osagiestar Jun 24, 2020
111b289
pass test program
osagiestar Jun 24, 2020
3416a3d
takes a number and outputs a result
osagiestar Jun 24, 2020
03d992d
grading result function
osagiestar Jun 24, 2020
ee9af80
learnt the use of str.includes()
osagiestar Jun 24, 2020
12f4621
array of strings and numbers
osagiestar Jun 24, 2020
c86035c
arr.lengthproperty
osagiestar Jun 24, 2020
48e81d0
array 1st and last values
osagiestar Jun 24, 2020
67329ae
push() function to add to the end of an index list
osagiestar Jun 24, 2020
0de3350
still working on the other questions
osagiestar Jun 24, 2020
239d6e1
learnt functions like slice, splice, sort(), join()
osagiestar Jun 25, 2020
4ba5c42
still working on the remaining questions
osagiestar Jun 25, 2020
f2d271b
last two questions to be attempted
osagiestar Jun 25, 2020
998d1a1
one more task to complete
osagiestar Jun 25, 2020
9f821e8
still working on task
osagiestar Jun 26, 2020
d6968ea
learnt how to debug and used console.log() to perform checks
osagiestar Jun 28, 2020
a1a4eb9
learnt how to debug and used console.log() to perform checks
osagiestar Jun 28, 2020
2b0331e
learnt to parseFloat method
osagiestar Jun 29, 2020
a151e32
tested on repl.it but not passing
osagiestar Jun 29, 2020
0aeb8e7
applied push method and added return which I missed before
osagiestar Jun 29, 2020
3b55575
applied filter method and used arrow method
osagiestar Jul 1, 2020
03eb52b
learnt map method and used parseFloat
osagiestar Jul 1, 2020
e3dd10d
applied the find method
osagiestar Jul 2, 2020
412cd9f
applied the process.exit(1) for termination of execution
osagiestar Jul 2, 2020
5fdf991
Updated the task
osagiestar Jul 2, 2020
54288e7
updated the file/task
osagiestar Jul 2, 2020
0751024
applied split and filter methods
osagiestar Jul 3, 2020
833a6a5
filter and map methods used
osagiestar Jul 5, 2020
2ceca37
applied includes() method
osagiestar Jul 6, 2020
2b3f4a3
applied includes() method with filter and map methods
osagiestar Jul 6, 2020
c73816b
need to practice RegEx more
osagiestar Jul 6, 2020
734d489
cleaned up code
osagiestar Jul 6, 2020
eb9c523
still working on it
osagiestar Jul 6, 2020
bdf6040
resolving conflicts
osagiestar Jul 7, 2020
967b433
debugging after feedback
osagiestar Jul 8, 2020
2983e66
debugging from feedback
osagiestar Jul 8, 2020
ebfb1c3
debugging from assessor's feedback
osagiestar Jul 8, 2020
7ed52af
debugging based on feedback
osagiestar Jul 8, 2020
d5a9312
debugging codes
osagiestar Jul 8, 2020
1a6f7de
exercises completed and feedback implemented
osagiestar Jul 8, 2020
221a09b
calling function method
osagiestar Jul 8, 2020
8ece4b1
corrected error
osagiestar Jul 8, 2020
4a7a7a1
debugging
osagiestar Jul 10, 2020
0bf0f1f
debugging
osagiestar Jul 10, 2020
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
10 changes: 5 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Your Details

Your Name:
Your City:
Your Slack Name:
Your Name: Osagie Okoedo
Your City: Birmingham
Your Slack Name: Osagie Okoedo

# Homework Details

Module:
Week:
Module: JavaScript
Week: 1
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
11 changes: 10 additions & 1 deletion week-1/1-exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
console.log("Hello world");
/* console.log() with quotes, single or double, returns the message on the console*/
console.log("Hello world. I just started learning JavaScript!");
console.log('Hello world. I just started learning JavaScript!');
console.log("Hello world. I just started learning JavaScript!");

/*Without the quote marks, I see an error message (SyntaxError: missing) */
console.log(Hello world. I just started learning JavaScript!);

/* with just a number and no quotes the output is the number */
console.log(4);
6 changes: 5 additions & 1 deletion week-1/1-exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Start by creating a variable `greeting`
/* * */

let greeting = "Hello world";

console.log(greeting);
console.log(greeting);
console.log(greeting);
2 changes: 2 additions & 0 deletions week-1/1-exercises/D-strings/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Start by creating a variable `message`

let message = "This is a string";
console.log(message);
console.log(typeof message);
5 changes: 3 additions & 2 deletions week-1/1-exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Start by creating a variable `message`

console.log(message);
let greeting = "Hello, my name is ";
let name = "Osagie";
console.log(greeting + name);
12 changes: 8 additions & 4 deletions week-1/1-exercises/F-strings-methods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ You can find out how many characters there are in a string by using the `length`
var name = "Daniel";
var nameLength = name.length;

console.log(nameLength); // Logs 6
console.log(nameLength); // Logs 6var message = "This is a string";
// var messageType = typeof message;

// console.log(message);
// console.log(messageType);
```

You can also get a modified version of a string by calling _string methods_. Let's try one:
Expand All @@ -20,7 +24,7 @@ You can find out more about string properties and methods by searching for "Java

## Exercise 1

* Log a message that includes the length of your name
- Log a message that includes the length of your name

## Expected result

Expand All @@ -30,8 +34,8 @@ My name is Daniel and my name is 6 characters long

## Exercise 2

* Log the same message using the variable, `name` provided
* Use the `.trim` method to remove the extra whitespace
- Log the same message using the variable, `name` provided
- Use the `.trim` method to remove the extra whitespace

## Expected result

Expand Down
18 changes: 18 additions & 0 deletions week-1/1-exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// Start by creating a variable `message`

// Ecercise 1 //
let name = "Osagie";
let namelength = name.length;
let message =
"My name is " + name + " and my name is " + namelength + " characters long";
console.log(message);

// Exercise 2 //
// For this exercise, I made spaces before and after name//
let nameWithSpace = " Osagie ";
let nameTrimmed = nameWithSpace.trim();
let namelength = nameWithSpace.length;
let message =
"My name is " +
nameTrimmed +
" and my name is " +
nameTrimmed.length +
" characters long";
console.log(message);
10 changes: 9 additions & 1 deletion week-1/1-exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Exercise 2 //
const name = " Daniel ";

let nameTrimmed = name.trim();
let namelength = nameTrimmed.length;
let message =
"My name is " +
nameTrimmed +
" and my name is " +
nameTrimmed.length +
" characters long";
console.log(message);
9 changes: 8 additions & 1 deletion week-1/1-exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
let numberOfStudents = 15;
let numberOfMentors = 8;

let totalOfStudentsAndMentors = numberOfStudents + numberOfMentors;
let message = "Total number of students and mentors: ";

console.log(message + totalOfStudentsAndMentors);
console.log(`${message}${totalOfStudentsAndMentors}`);
18 changes: 18 additions & 0 deletions week-1/1-exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
var numberOfStudents = 15;
var numberOfMentors = 8;
let totalofStudentsAndMentors = numberOfStudents + numberOfMentors;

let percentOfStudents = (numberOfStudents / totalofStudentsAndMentors) * 100;
let percentOfMentors = (numberOfMentors / totalofStudentsAndMentors) * 100;

let approxPercent = Math.round(percentOfStudents);
let approxPer = Math.round(percentOfMentors);
let comment1 = "Percentage students:";
let comment2 = "Percentage mentors:";

// console.log(percentOfStudents);
// console.log(percentOfMentors);

// console.log(approxPercent);
// console.log(approxPer);

console.log(`${comment1} ${approxPercent}%`);
console.log(`${comment2} ${approxPer}%`);
8 changes: 6 additions & 2 deletions week-1/1-exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
function halve(number) {
// complete the function here
return number / 2; // complete the function here
}

var result = halve(12);
let output = halve(12);
let result = halve(50);
let value = halve(36);

console.log(output);
console.log(result);
console.log(value);
4 changes: 2 additions & 2 deletions week-1/1-exercises/J-functions/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function triple(number) {
// complete function here
return number * 3;
}

var result = triple(12);
let result = triple(12);

console.log(result);
12 changes: 5 additions & 7 deletions week-1/1-exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Complete the function so that it takes input parameters
function multiply() {
// Calculate the result of the function and return it
}

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

function multiply(a, b) {
return a * b;
}
let result = multiply(3, 4);
console.log(result);
6 changes: 4 additions & 2 deletions week-1/1-exercises/K-functions-parameters/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Declare your function first

var result = divide(3, 4);
function divide(a, b) {
return a / b;
}
let result = divide(3, 4);

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

var greeting = createGreeting("Daniel");

console.log(greeting);
function createGreeting(name) {
// let greeting = "Hello, my name is ";
// let fullGreeting = greeting + name;
let fullGreeting = "Hello, my name is " + name;
return fullGreeting;
}
console.log(createGreeting("Daniel"));
7 changes: 4 additions & 3 deletions week-1/1-exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Declare your function first

function sum(num1, num2) {
return num1 + num2;
}
// Call the function and assign to a variable `sum`

console.log(sum);
console.log(sum(13, 124)); // calling the function and passing the numbers
11 changes: 7 additions & 4 deletions week-1/1-exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Declare your function here

const greeting = createLongGreeting("Daniel", 30);

console.log(greeting);
function createLongGreeting(name, age) {
// let name = "Daniel";
// let age = 30;
const greeting = `My name is ${name} and I'm ${age} years old`;
return greeting;
}
console.log(createLongGreeting("Daniel", 30));
42 changes: 42 additions & 0 deletions week-1/1-exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
//Exercise 1//
function percentProgram(firstNumber, secondNumber) {
let overallTotal = firstNumber + secondNumber;

let percentage = Math.round((firstNumber / overallTotal) * 100);
return percentage;
}

function message(numberOfStudents, numberOfMentors) {
let percentOfStudents = percentProgram(numberOfStudents, numberOfMentors);
let percentOfMentors = percentProgram(numberOfMentors, numberOfStudents);
let fullMessage = `Percentage students: ${percentOfStudents}% Percentage mentors: ${percentOfMentors}%`;
return fullMessage;
}
let finalMessage = message(15, 8);
console.log(finalMessage);

// console.log(`${comment1} ${approxPercent}%`);
// console.log(`${comment2} ${approxPer}%`);

var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";

function shoutyGreeting(mentor) {
let nameUpperCase = mentor.toUpperCase();
let greeting = `HELLO ${nameUpperCase}`;
return greeting;
}

let greeting1 = shoutyGreeting(mentor1);
let greeting2 = shoutyGreeting(mentor2);
let greeting3 = shoutyGreeting(mentor3);
let greeting4 = shoutyGreeting(mentor4);
let greeting5 = shoutyGreeting(mentor5);

console.log(greeting1);

console.log(greeting2);

console.log(greeting3);

console.log(greeting4);

console.log(greeting5);
41 changes: 23 additions & 18 deletions week-1/2-mandatory/1-syntax-errors.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// There are syntax errors in this code - can you fix it to pass the tests?

function addNumbers(a b c) {
return 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;

// Use string interpolation here
return "The total is %{total}"
let total = a + b;
return `The total is ${total}`;
}

/* ======= TESTS - DO NOT MODIFY =====
Expand All @@ -20,19 +19,25 @@ There are some Tests in this file that will help you work out if your code is wo
To run these tests type `node 1-syntax-errors.js` into your terminal
*/

const util = require('util');
const util = require("util");

function test(test_name, actual, expected) {
let status;
if (actual === expected) {
status = "PASSED";
} else {
status = `FAILED: expected: ${util.inspect(expected)} but your function returned: ${util.inspect(actual)}`;
}

console.log(`${test_name}: ${status}`);
let status;
if (actual === expected) {
status = "PASSED";
} else {
status = `FAILED: expected: ${util.inspect(
expected
)} but your function returned: ${util.inspect(actual)}`;
}

console.log(`${test_name}: ${status}`);
}

test("fixed addNumbers function - case 1", addNumbers(3, 4, 6), 13);
test("fixed introduceMe function", introduceMe("Sonjide", 27), "Hello, my name is Sonjide and I am 27 years old");
test(
"fixed introduceMe function",
introduceMe("Sonjide", 27),
"Hello, my name is Sonjide and I am 27 years old"
);
test("fixed getTotal function", getTotal(23, 5), "The total is 28");
Loading