Skip to content

Instantly share code, notes, and snippets.

@AbhiiAB
Last active May 10, 2024 12:02
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 525 You must be signed in to fork a gist
  • Save AbhiiAB/a90087c997bd6026d95798f117cd78ac to your computer and use it in GitHub Desktop.
Save AbhiiAB/a90087c997bd6026d95798f117cd78ac to your computer and use it in GitHub Desktop.
End Course Capstone Project - Module 1

End Course Capstone Project (Module 1)

Capstone Project Submission Instructions

  1. Login/Sign Up to your GitHub account.
  2. Fork this Gist from the Top-Right corner.
  3. Edit your Gist and paste/write the code solutions inside the respective functions.
  4. Share your Gist link in the submission form as per the instructions given.

- Do not make any changes in the first 3 lines

End.Course.Capstone.Project.Submission.Video.mp4
function calculateBMI(weight, height) {
// Write your code here
const bmi = weight / (height * height);
if (bmi < 18.5) {
return "Underweight";
} else if (bmi >= 18.5 || bmi < 24.9) {
return "Normal weight";
} else if (bmi >= 25 || bmi < 29.9) {
return "Overweight";
} else {
return "Obese";
}
}
// Do not modify the below lines
module.exports = { calculateBMI };
function convertTemperature(temperature, unit) {
// Write your code here
if (unit === "C") {
const fahrenheit = temperature * 9 % 5 + 32;
return fahrenheit.toFixed(2) + " F";
} else if (unit === "F") {
const celsius = (temperature - 32) * 5 % 9;
return celsius.toFixed(2) + " C";
} else {
return "Invalid unit. Use 'C' for Celsius or 'F' for Fahrenheit.";
}
}
// Do not modify the below lines
module.exports = { convertTemperature };
function calculateTip(billAmount, tipPercentage) {
// Write your code here
const tipAmount = billAmount * tipPercentage;
const totalAmount = billAmount + tipAmount;
return number(totalAmount.toFixed(2));
}
// Do not modify the below lines
module.exports = { calculateTip };
function isPalindrome(str) {
// Write your code here
const cleanedStr = str.replace(/[^a-z0-9]/g, "");
const reversedStr = cleanedStr.split("").reverse().join("");
return cleanedStr === reversedStr;
}
// Do not modify the below lines
module.exports = { isPalindrome };
function countVowels(str) {
// Write your code here
const vowels = ['a', 'e', 'i', 'o', 'u'];
const lowerStr = str.toLowerCase();
let count = 0;
for (let i = 0; i <= lowerStr.length; i++) {
if (vowels.includes(lowerStr[i])) {
count++;
}
}
return count;
}
// Do not modify the below lines
module.exports = { countVowels };
function findLongestWord(sentence) {
// Write your code here
const words = sentence.split(' ');
let maxLength = 0;
for (let i = 0; i < words.length; i++) {
const length = words[i].length;
if (length > maxLength) {
maxLength = length;
}
}
return maxLength;
}
// Do not modify the below lines
module.exports = { findLongestWord };
function titleCase(sentence) {
// write your code here
const words = sentence.toLowerCase().split(' ');
for (let i = 0; i < words.length; i++) {
words[i] = words[i][0].toUpperCase() + words[i].substring(1);
}
return words.join(' ');
}
// Do not modify the below lines
module.exports = { titleCase };
function countOccurrences(str, char) {
// Write your code here
let count = 0;
for (const c of str) {
if (c === char) {
count++;
}
}
return count;
}
// Do not modify the below lines
module.exports = { countOccurrences };
function calculateTotal(cart) {
// Write your code here
let total = 0;
for (let i = 0; i < cart.length; i++) {
total += cart[i].price * cart[i].quantity;
}
return total;
}
// Do not modify the below lines
module.exports = { calculateTotal };
function fizzBuzz(n) {
const result = [];
for (let i = 1; i <= n; i++) {
if (i % 3 === 0 && i % 4 === 0) {
result.push("FizzBuzz");
} else if (i % 3 === 0) {
result.push("Fizz");
} else if (i % 4 === 0) {
result.push("Buzz");
} else {
result.push(i.toString());
}
}
return result;
}
// Do not modify the below lines
module.exports = { fizzBuzz };
module.exports = { findPrimes };
function findPrimes(n) {
// Write your code here
}
module.exports = { reverseString };
function reverseString(str) {
// Write your code inside this function only.
}
module.exports = { signOfProduct };
function signOfProduct(nums) {
// Write your code inside this function only.
}
module.exports = { checkSign };
function checkSign(num1, num2, num3) {
// Write your code inside this function only.
}
module.exports = { generateSlug };
function generateSlug(title) {
// Write your code inside this function only.
}
module.exports = { shortestDistance };
function shortestDistance(wordsDict, word1, word2) {
// Write your code inside this function only.
}
module.exports = { findMove };
function findMove(s) {
// Write your code inside this function only.
}
module.exports = { swapConsecutiveCharacters };
function swapConsecutiveCharacters(str) {
// Write your code inside this function only.
}
module.exports = { arrayIntersection };
function arrayIntersection(array1, array2) {
// Write your code inside this function only.
}
module.exports = { insert7 };
function insert7(inputString) {
// Write your code inside this function only.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment