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() { diff --git a/November/Palidrome.js b/November/Palidrome.js new file mode 100644 index 0000000..df4297f --- /dev/null +++ b/November/Palidrome.js @@ -0,0 +1,19 @@ +// [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 */ + +// Declaration function +function palindrome(str){ + var len = str.length; // assign the length of string + var mid = Math.floor(len / 2); //round down the length of string + +// checking the string + 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(palindrome("abba")); // true