Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PP FT MEX - Otto Emiliano#466

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Changes fromall 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
56 changes: 55 additions & 1 deletionstarter-code/basic-algorithms.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,61 @@
// Names and Input
let hacker1 = 'Emiliano Popoca'

console.log(`The driver's name is ${hacker1}`)

let hacker2 = prompt('Enter the navigator name')

console.log(`The navigator's name is ${hacker2}`)

//Conditionals
let h1Length = hacker1.length
let h2Length = hacker2.length

if (h1Length > h2Length) {
console.log(`The driver has the longest name. It has ${h1Length} characters.`)
} else if (h1Length < h2Length) {
console.log(`Yo, Navigator got the longest name. It has ${h2Length} characters.`)
} else {
console.log(`Wow, you both got equally long names, ${h2Length} characters.`)
}

hacker1.toUpperCase().split('').join(' ')

hacker1.split('').reverse().join('')


let harray = [hacker1.toUpperCase(), hacker2.toUpperCase()].sort()
console.log(harray)

if (hacker2.toUpperCase()== hacker1.toUpperCase()) {
console.log(`What?! You both got the same name.`)
}
else if (harray[0]== hacker1.toUpperCase()) {
console.log(`The driver's name goes first`)
} else if (harray[0]== hacker2.toUpperCase()) {
console.log(`Yo, the navigator goes first definately.`)
}



// Palindrome and Lorem ipsum generator
let palindromeText = prompt('Please enter Palindrome text.')

let cleanText = palindromeText.replace(/[^A-Z\d]/gi, '').toUpperCase()

let okTick = false;
for (i=0; i<Math.floor((cleanText.length)/2); i++)
{
if (cleanText[i]===cleanText[cleanText.length-1-i]) {
okTick = true;
} else {
okTick = false;
break;
}
}

// Lorem ipsum generator
if (okTick === true) {
console.log('It is a Palindrome!!! ;)')
} else {
console.log('It is not a Palindrome ;(')
}

[8]ページ先頭

©2009-2025 Movatter.jp