Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Palidrome #28

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions November/BodyMassIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
19 changes: 19 additions & 0 deletions November/Palidrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// [November]/[Day 4]/[Javascript]/{Palidrome.js}
xxxSkypper marked this conversation as resolved.
Show resolved Hide resolved

/* 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