Skip to content

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