Skip to content

Commit

Permalink
update2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayman-matoo committed Dec 8, 2023
1 parent 1541dd8 commit f275546
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 16 deletions.
2 changes: 1 addition & 1 deletion week-1/exercises/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ console.log(lastSlashIndex);
// Create a variable to store the ext part of the variable
let = filePath ("/")
console.log (dirPart,filePath);

const
console.log(filePath+ lastSlashIndex)
6 changes: 4 additions & 2 deletions week-1/interpret/percentage-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ console.log(`The percentage change is ${percentageChange}`);
// Read the code and then answer the questions below

// a) How many function calls are there in this file? Write down all the lines where a function call is made

There are four function
line 1 line 2 , line line 7 and line 8
// b) Identify all the lines that are variable reassignment statements

line 1 is carpeice line 2 is priceAfterOneYear , line 7 priceDifference line 8 priceDifference
// c) Identify all the lines that are variable declarations
var to 10000 , var is "8553" , var 7 is carPrice -priceAfterOneYear and var 8 priceDifference / carPrice

// d) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
2 changes: 1 addition & 1 deletion week-1/interpret/time-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ console.log(result);
// For the piece of code above, read the code and then answer the following questions

// a) How many variable declarations are there in this program?

there are seven variable declared
// b) How many function calls are there?

// c) Using documentation on MDN, explain what the expression movieLength % 60 represents
Expand Down
6 changes: 3 additions & 3 deletions week-2/errors/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// this function should square any number but instead we're going to get an error
// what is happening? How can we fix it?

function square {
function square (num) {
return num * num;

}
var result = square(3);
console.log("square" (3));

console.log("square" (8));



11 changes: 6 additions & 5 deletions week-2/implement/bmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
// When we call this function with the weight and height
// Then it returns their Body Mass Index to 1 decimal place

function bmi (w,h){
h = h*h;
let x = h/w;
return (x);
function bim (weigh,height){
height = height*weigh;
let bim = ("weigh*height");

}
console.log(Bmi("60"));

console.log(bim);
8 changes: 8 additions & 0 deletions week-2/implement/cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
// When we call this function with the input string
// Then it returns the string in UPPER_CAMEL_CASE, so "HELLO_THERE"


function cases (str){
str =`${str.Uppercase()}`
str =`${str.Snake_cases()}`
return
}
console.log("cases");

// Test case: we expect "lord of the rings" to be "LORD_OF_THE_RINGS"
// Test case: we expect "the great gatsby" to be "THE_GREAT_GATSBY"
// Test case: we expect "the da vinci code" to be "THE_DA_VINCI_CODE"
Expand Down
8 changes: 5 additions & 3 deletions week-2/implement/to-pounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// Take this code and turn it into a reusable block of code.
// Declare a function called toPounds with an appropriately named parameter.
// Call this function a number of times to check it works for different inputs
function toPounds(meat){
const meatstring
function toPounds(jainnah){
return `${Number( jainnah / 1200).toFixed(2)} pounds`;


}
console.log(num);
console.log(toPounds(20));
18 changes: 18 additions & 0 deletions week-3/implement/get-angle-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@
// Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"


function getAngleType(angle){
if (angle==90){
return "right angle";
} else if(angle < 90){
return "acute angle";
} else if (angle == 180){
return "straight angle";
} else if (angle >90 && angle <180){
return "obtuse angle";
} else if (angle >180 && angle <360){
return "reflex angle";
} else {
return "invalid";
}
}
console.log(getAngleType(90));
16 changes: 16 additions & 0 deletions week-3/implement/get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,19 @@
// Given a card with an invalid rank (neither a number nor a recognized face card),
// When the function is called with such a card,
// Then it should throw an error indicating "Invalid card rank."
function getCardValue(card){
const rank = card.slice(0,-1)
if (rank >=2 && rank<= 10){
return parseInt(rank);
}
if (["j" ,"Q","R"].includes(rank)){
return 10;
}
if (rank =="A"){
return 11;
}
else {
return "invalid card rank"
}
}
console.log("getCardValue()");
26 changes: 26 additions & 0 deletions week-3/implement/is-proper-fraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,29 @@
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.

// These acceptance criteria cover a range of scenarios to ensure that the isProperFraction function handles both proper and improper fractions correctly and handles potential errors such as a zero denominator.

// Define the function
function isProperFraction(numerator, denominator) {
var x = numerator;
var y = denominator;

var outputVal = x % y;
if (outputVal > 0) {
return false;
} else {
return true;
}
}

// Call the function with some example values
var numeratorExample = 14;
var denominatorExample = 2;

var result = isProperFraction(numeratorExample, denominatorExample);

// Log the result to the console
if (result === true) {
console.log("target output: true");
} else {
console.log("target output: false");
}
12 changes: 12 additions & 0 deletions week-3/implement/is-valid-triangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@
// Then it should return true because the input forms a valid triangle.

// This specification outlines the behavior of the isValidTriangle function for different input scenarios, ensuring it properly checks for invalid side lengths and whether they form a valid triangle according to the Triangle Inequality Theorem.

function isValidTriangle(a, b, c) {
if (a <= 0 || b <= 0 || c <= 0) {
return "false";
} ;
if (a - b <= c || a + c <= b || b + c <= a) {
return "false";
else {
return true;
}
}
console.log(isValidTriangle(3, 7, 2));
16 changes: 16 additions & 0 deletions week-3/refactor/format-as-12-hours.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,19 @@
// Store this expression in a variable and reference it twice in the function in the correct place

// Explain why it makes more sense to store this expression in a variable

function formatAs12Hours(time) {
const hours24 = Number(time.slice(0, 2));

if (hours24 < 0 || hours24 > 23) {
return "Invalid hours in time string"; // check vaild in 24hours fromat
} else if (hours24 === 0) {
return "midnight";
} else {
const hours12 = hours24 % 12;
const period = hours24 < 12 ? "AM" : "PM";
return `${hours12 === 0 ? 12 : hours12}:${time.slice(3)} ${period}`;
}
}

console.log(formatAs12Hours("08:30")); // Example usage
2 changes: 1 addition & 1 deletion week-3/refactor/is-vowel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function isVowel(letter) {
return (
letter === "a" ||
letter === "e" ||
letter === "i" ||
// letter === "i" ||
letter === "i" ||
letter === "o" ||
letter === "u"
Expand Down

0 comments on commit f275546

Please sign in to comment.