From 2b4b1398ee50a65f8744849afd8ccea4a7f3f8ae Mon Sep 17 00:00:00 2001 From: xxxSkypper Date: Sat, 6 Nov 2021 00:40:06 +0100 Subject: [PATCH 1/3] Palidrome --- November/Palidrome.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 November/Palidrome.js diff --git a/November/Palidrome.js b/November/Palidrome.js new file mode 100644 index 0000000..19edecd --- /dev/null +++ b/November/Palidrome.js @@ -0,0 +1,18 @@ +// [November]/[Day 4]/[Javascript]/{Palidrome.js} + +/* Given a string, return true if the string is a palindrome or false if it is not. Palindromes are strings that form the same word if it is reversed. Do include spaces and punctuation in determining if the string is a palindrome. Make use of Functions and Methods where necessory */ + +function palidrome(str){ + var len = str.length; // assign the length of string + var mid = Math.floor(len / 2); //round down + +// checking the string + for (let i = 0; i < mid; i++){ + if (str[i] !== str[len - 1 - i]) { + return false; + } + } + return true; +} + +console.log(palidrome("abba")); // true \ No newline at end of file From bcbd20e40c879e90670ecc437197b72ad9a1cbad Mon Sep 17 00:00:00 2001 From: Kevin <77277779+xxxSkypper@users.noreply.github.com> Date: Fri, 5 Nov 2021 23:33:20 +0100 Subject: [PATCH 2/3] Calculate Body Mass Index --- November/BodyMassIndex.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/November/BodyMassIndex.js b/November/BodyMassIndex.js index 23dbdd5..0175356 100644 --- a/November/BodyMassIndex.js +++ b/November/BodyMassIndex.js @@ -5,8 +5,8 @@ // but we know BMI = mass/height**2 let age = prompt("Enter your age"); // prompt the user to enter he or she age -let weight= prompt("Enter your weight "); // prompt the user to enter he or she age -let height= prompt("Enter your height"); // prompt the user to enter he or she age +let weight= prompt("Enter your weight "); // prompt the user to enter he or she weight +let height= prompt("Enter your height"); // prompt the user to enter he or she height const BMI = weight / (height ** 2); // formula of Body Mass Index function bmi() { From dbffcd23936f89d3a866b0dcc0b2d5421368a6be Mon Sep 17 00:00:00 2001 From: Kevin <77277779+xxxSkypper@users.noreply.github.com> Date: Fri, 5 Nov 2021 23:54:41 +0100 Subject: [PATCH 3/3] Palindrome --- November/Palidrome.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/November/Palidrome.js b/November/Palidrome.js index 19edecd..df4297f 100644 --- a/November/Palidrome.js +++ b/November/Palidrome.js @@ -2,17 +2,18 @@ /* Given a string, return true if the string is a palindrome or false if it is not. Palindromes are strings that form the same word if it is reversed. Do include spaces and punctuation in determining if the string is a palindrome. Make use of Functions and Methods where necessory */ -function palidrome(str){ +// Declaration function +function palindrome(str){ var len = str.length; // assign the length of string - var mid = Math.floor(len / 2); //round down + var mid = Math.floor(len / 2); //round down the length of string // checking the string - for (let i = 0; i < mid; i++){ - if (str[i] !== str[len - 1 - i]) { + for (let i = 0; i < mid; i++){ // iterate through string + if (str[i] !== str[len - 1 - i]) { // checking whether the string are thesame or not when reverse it return false; } } return true; } -console.log(palidrome("abba")); // true \ No newline at end of file +console.log(palindrome("abba")); // true