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

added: my solutions in javascript to the caesar cipher challenge #76

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ederalab
Copy link
Contributor

No description provided.

const letters = 26;

function encode(str, shift) {
shift = shift % letters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a new constant value instead of re-assigning the function parameter 🙂

if ((character >= "a" && character <= "z") || (character >= "A" && character <= "Z")) {
// if is lowercase
if (character >= "a" && character <= "z") {
ascii = 97
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this ascii variable come from?

ascii = 65
}

new_str = letters + character.charCodeAt(0) - ascii
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please instantiate a new variable by using let or const keywords

}


function decode(str, shift) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you're repeating most of the encode function. Is there a way to avoid all those repetitions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants