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

Creating Unnecessary Variables #3

Open
shohtime opened this issue Jul 1, 2019 · 0 comments
Open

Creating Unnecessary Variables #3

shohtime opened this issue Jul 1, 2019 · 0 comments

Comments

@shohtime
Copy link

shohtime commented Jul 1, 2019

const paddedString = ' '.repeat(startPadding) + string + ' '.repeat(endPadding);
return paddedString;

This might seem nitpicky, but one of the main jobs of programmers is to be as efficient as possible. Whenever we create a variable, our computer creates space in its memory for that variable, so it is best to avoid creating them if they're unnecessary. For this code, instead of creating a new variable you can just return the expression that you set paddedString equal to.

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

No branches or pull requests

1 participant