You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.0 KiB
JavaScript

// console.log("Hello World");
//Objective 1
//Add code here
//Note: function name is numberLooper
function numberLooper(number) {
let message = '';
for (let count = number; count >= 0; count--) {
if (count <= 50) {
message = "The current value is at " + count + " Terminating the loop.";
break;
}
if (count % 10 === 0) {
console.log('The number is divisible by 10. Skipping the number.');
continue;
}
if (count % 5 === 0) {
console.log(count);
}
}
return message;
}
//let loopCount = parseInt(prompt("Enter number of loops"));
//console.log("numberLooper(" + loopCount + ")");
//let numLooper = numberLooper(loopCount);
console.log("numberLooper(65)");
let numLooper = numberLooper(65);
console.log(numLooper);
//Objective 2
let string = 'supercalifragilisticexpialidocious';
console.log(string);
let filteredString = '';
for(let i = 0; i < string.length; i++){
if (
string[i].toLowerCase() == "a" ||
string[i].toLowerCase() == "i" ||
string[i].toLowerCase() == "u" ||
string[i].toLowerCase() == "e" ||
string[i].toLowerCase() == "o"
){
// If the letter in the name is a vowel, it will print the number 3
continue;
} else {
// Print in the console all non-vowel characters in the name
filteredString = filteredString + string[i];
}
}
console.log(filteredString);
//Add code here
//Do not modify
//For exporting to test.js
//Note: Do not change any variable and function names. All variables and functions to be checked are listed in the exports.
try{
module.exports = {
filteredString: typeof filteredString !== 'undefined' ? filteredString : null,
numberLooper: typeof numberLooper !== 'undefined' ? numberLooper : null
}
} catch(err){
}