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
48 changes: 48 additions & 0 deletions exercises/B-hello-world/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
console.log("Hello world");
console.log("Testing console.log");
console.log("Show a lot to do.");
console.log("Amazing console that LOG");

let person1 = " Israel ";
let activity = " Skateboarding ";
let goOut = " To the park ";
let likes = "It is a person who likes";
let noLikes = "It is a person who do not likes";
let numberBig = 1324123451235;
let isTrueOr = true;
let isFalseOr = false;
let story =
isFalseOr +
isTrueOr +
person1 +
numberBig +
noLikes +
" play baseball" +
" his " +
activity +
" is better than anything";

console.log("begin of the story");
console.log(story);

function myFunctionName() {
console.log(goOut);
console.log(likes);
console.log(story);
}

console.log("the function results");
myFunctionName();

function someTest(num1, num2, num3, num4) {
return "The numbers you gave us SUM: " + num1 + num2 + num3 + num4;
}
console.log("sum");
someTest(700, 44, 600, 100);

//Experiment
console.log("This is the test with out quotes");
console.log(
"If you do not use quotes an error message will appear to you saying: SyntaxError: missing ) after argument list"
);
console.log(100);
console.log("Console.log works with numbers too, with out quotes");
5 changes: 4 additions & 1 deletion exercises/C-variables/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Start by creating a variable `greeting`

let greeting = "Hello World";
console.log(greeting);
console.log(greeting);
console.log(greeting);

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

let message = "This is a string"
//log
console.log(message);


let messageType = typeof message;
console.log(messageType);
//log
console.log(typeof(message));


let myMessage = "Using typeof command to know what data type is and this is: "
let myMsmDataType = typeof myMessage;
//log
console.log(myMessage,myMsmDataType);

6 changes: 5 additions & 1 deletion exercises/E-strings-concatenation/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Start by creating a variable `message`
let message = "Hello, my name is ";
let myName = "Israel";
let greeting = message + myName;
//log
console.log(greeting);

console.log(message);
25 changes: 24 additions & 1 deletion exercises/F-strings-methods/exercise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
// Start by creating a variable `message`

console.log(message);
let myName = "Israel";
let nameLength = myName.length;
//log
console.log(nameLength);

//Using string methods
let myNameInLowerCase = myName.toLowerCase();
//log
console.log(myNameInLowerCase);

let exerciseOne =
"My name is " + myName + " and my name is " + nameLength + " characters long";
//log
console.log(exerciseOne);

const name = " Daniel ";

//log
let exerciseTwo = "My name is " + name + " and my name is " + nameLength + " characters long";
console.log(exerciseTwo);
//With trim
exerciseTwo = "My name is " + name.trim() + " and my name is " + nameLength + " characters long";
console.log(exerciseTwo);

5 changes: 4 additions & 1 deletion exercises/F-strings-methods/exercise2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const name = " Daniel ";

console.log(message);
let exerciseOne =
"My name is " + name+ " and my name is " + nameLength + " characters long";
//log
console.log(exerciseOne);
17 changes: 17 additions & 0 deletions exercises/G-numbers/exercise.js
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
// Start by creating a variables `numberOfStudents` and `numberOfMentors`
let age = 37;
let sum = 10 + 234;
let product = 245 * 23;
let quotient = 10 / 2;
let difference = 10 - 4;

//Exercises

let numberOfStudents = 100;
let numberOfMentors = 25;

console.log(
"Total number of student: " +
numberOfStudents +
" and mentors: " +
numberOfMentors
);
24 changes: 22 additions & 2 deletions exercises/I-floats/exercise.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
var numberOfStudents = 15;
var numberOfMentors = 8;

let numberOfStudents = 15;
let numberOfMentors = 8;

//Some test
let preciseAge = 30.612437;
//get that number rounded using Math.round
let roughAge = Math.round(preciseAge);
//log
//console.log(roughAge); //31

//lets sum both values Student and Mentors
let totalAmount = numberOfMentors+numberOfStudents;
//Divide - multiply and round
let percentageValue = Math.round((numberOfStudents/totalAmount)*100);
//log for students
console.log("Percentage students "+percentageValue+"%");

//Divide - multiply and round
percentageValue = Math.round((numberOfMentors/totalAmount)*100);
//log for metors
console.log("Percentage mentors "+percentageValue+"%");
12 changes: 10 additions & 2 deletions exercises/J-functions/exercise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
function halve(number) {
// complete the function here
return number / 2;
}

var result = halve(12);

//log
console.log(result);
//log-1
result = halve(245);
//log
console.log(result);
//log-2
result = halve(59934);
//log
console.log(result);
4 changes: 2 additions & 2 deletions 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);
6 changes: 3 additions & 3 deletions exercises/K-functions-parameters/exercise.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Complete the function so that it takes input parameters
function multiply() {
// Calculate the result of the function and return it
function multiply(num01, num02) {
return num01 * num02;
}

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

console.log(result);
6 changes: 4 additions & 2 deletions 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);
let result = divide(3, 4);

console.log(result);
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Write your function here
function createGreeting (str){
return "Hello, my name is " + str;
}

var greeting = createGreeting("Daniel");
let greeting = createGreeting("Daniel");

console.log(greeting);
6 changes: 4 additions & 2 deletions exercises/K-functions-parameters/exercise4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Declare your function first
function addition (num1, num2){
return num1 + num2;
}

// Call the function and assign to a variable `sum`
let sum = addition(13,124);

console.log(sum);
4 changes: 3 additions & 1 deletion exercises/K-functions-parameters/exercise5.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Declare your function here
function createLongGreeting(str, ages) {
return "Hello, my names is " + str + " and I'm " + ages + " years old";
}

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

Expand Down
23 changes: 18 additions & 5 deletions exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
let mentor1 = "Daniel";
let mentor2 = "Irina";
let mentor3 = "Mimi";
let mentor4 = "Rob";
let mentor5 = "Yohannes";

function uppercaseNames (str){
return nameUppercased = str.toUpperCase();
}

function shoutyGreet (name){
return "HELLO "+uppercaseNames(name);
}
console.log(shoutyGreet(mentor1));
console.log(shoutyGreet(mentor2));
console.log(shoutyGreet(mentor3));
console.log(shoutyGreet(mentor4));
console.log(shoutyGreet(mentor5));
15 changes: 12 additions & 3 deletions extra/1-currency-conversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@
Write a function that converts a price to USD (exchange rate is 1.4 $ to £)
*/

function convertToUSD() {}
function convertToUSD(price) {
return price * 1.4;
}
console.log(convertToUSD(32));

/*
CURRENCY CONVERSION
===================
The business is now breaking into the Brazilian market
Write a new function for converting to the Brazilian real (exchange rate is 5.7 BRL to £)
They have also decided that they should add a 1% fee to all foreign transactions, which means you only convert 99% of the £ to BRL.
They have also decided that they should add a 1% fee to all foreign transactions,
which means you only convert 99% of the £ to BRL.
*/

function convertToBRL() {}
function convertToBRL(priceB) {
substPercent = priceB * .99 ;
return substPercent * 5.7;
}

console.log(convertToBRL(30));

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand Down
38 changes: 28 additions & 10 deletions extra/2-piping.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
- one that multiplies 2 numbers together
- one that formats a number so it's returned as a string with a £ sign before it (e.g. 20 -> £20)

2. Using the variable startingValue as input, perform the following operations using your functions all
2. Using the variable startingValue as input, perform the following operations
using your functions all
on one line (assign the result to the variable badCode):
- add 10 to startingValue
- multiply the result by 2
Expand All @@ -16,26 +17,43 @@
the final result to the variable goodCode
*/

function add() {

function add(num1, num2) {
return num1 + num2;
}

function multiply() {

function multiply(num1, num2) {
return num1 * num2;
}

function format() {

function format(number) {
return "£" + number;
}

const startingValue = 2;

// Why can this code be seen as bad practice? Comment your answer.
let badCode =
let badCode = format((multiply(add(startingValue,10),2))); //I never think to write this without your help CYF
//Is a bad code I know but I understand what I wrote
console.log(badCode);

/*BETTER PRACTICE */

function performOperations (numToAdd, numToMultiply){
sum = numToAdd + startingValue;
multiplication = sum * numToMultiply;
return "£" + multiplication;
}

let goodCode = performOperations(10,2);

/* BETTER PRACTICE */
console.log(goodCode);
/* £££ UNCOMMENT THIS CODE TO RUN WITH FIXED VALUES $$$

let goodCode =
function performOperations (){
sum = 10 + startingValue;
multiplication = sum * 2;
return "£" + multiplication;
*/

/* ======= TESTS - DO NOT MODIFY =====
There are some Tests in this file that will help you work out if your code is working.
Expand Down
Loading