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

Java script core 1 homework/week1/osagie #32

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 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
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
Prev Previous commit
learnt function in a function method
  • Loading branch information
osagiestar committed Jun 20, 2020
commit c68d50fdcc3bb82c3166ee9e03dc166b0c5562f0
30 changes: 25 additions & 5 deletions week-1/1-exercises/L-functions-nested/exercise.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
var mentor1 = "Daniel";
var mentor2 = "Irina";
var mentor3 = "Mimi";
var mentor4 = "Rob";
var mentor5 = "Yohannes";
//Exercise 1//
function percentProgram(firstNumber, secondNumber) {
let overallTotal = firstNumber + secondNumber;
Copy link

Choose a reason for hiding this comment

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

Here you have demonstrated using function parameters nicely so I'm sure you can correct the other exercises above :)


let percentage = Math.floor((firstNumber / overallTotal) * 100);
Copy link

Choose a reason for hiding this comment

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

Running this exercise returns 65% for students and 34% for mentors. The total is 99% not 100%, can you think why?

return percentage;
}

function message(numberOfStudents, numberOfMentors) {
let percentOfStudents = percentProgram(numberOfStudents, numberOfMentors);
let percentOfMentors = percentProgram(numberOfMentors, numberOfStudents);
let fullMessage = `Percentage students: ${percentOfStudents}% and 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";