Git Product home page Git Product logo

pjs-capstone-lodash's People

Contributors

christiantravelling avatar

pjs-capstone-lodash's Issues

Creating Unnecessary Variables

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.

Redundant Code

let isInRange = false;
if (number >= start && number < end) {
return isInRange = true;
}
else {isInRange = false}
return isInRange;

Although this is entirely correct, it is a very redundant set of code. In fact, it can be simplified to just 1 line, and you have already written it. A boolean variable can be replaced with an expression, because all expressions simplify to either true or false. Knowing that, you can replace all of this code with just the conditional you placed in the if statement: number >= start && number < end.

Unnecessary Variables Part 2

const predicateReturnValue = predicate(value);
if (predicateReturnValue) {

This is an important concept so I'm going to go into a little more detail, as the other example was just once case. Generally, if you only use a variable once after creating it, you don't need to create a variable. Here, you could have just written if(predicate(value)). Not only do you save memory, you also save time. This is one additional line that the computer will no longer have to read. Now, one line may not seem like much, but keep in mind that this one line is in a for-loop, so you're actually saving time with every single iteration!

Summary

Rubric Score

Criteria 1: Functionality

  • Score Level: 3 (Meets Expectations)
  • Comment(s): All main functionality and edge cases are properly implemented. All tests in the test suite are passing.

Criteria 2: Code Style - Formatting

  • Score Level: 3 (Meets Expectations)
  • Comment(s): All code is consistently indented and formatted. All indents are the same size. Each new block is indented at the beginning of the block's content and unindented after the block ends. Every line that should end in a semi-colon does. Only one empty line is added when line breaks are being used. Variable are named descriptively.

Criteria 3: Code Style - JavaScript Techniques

  • Score Level: 2 (Meets Expectations)
  • Comment(s): Code demonstrates some good practices, but could be optimized for an ES6+ world. Variables are declared, though often not with appropriate keywords.

Overall Score: {8/12}

Great work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.