Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="https://wzrd.in/standalone/tape@latest"></script>
<script src="https://wzrd.in/standalone/tap-browser-color@latest"></script>
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script>
<script>
  window.test = tape;
  tapBrowserColor();
</script>
  
              
            
!

CSS

              
                
              
            
!

JS

              
                `
Write a lookup() function that takes login and a property as
arguments and returns the property value.

The function should check if login is an actual user and the given
property is a property of that contact.

If both are true, then return the "value" of that property.

If login is not found, return an error with the message,
"Could not find user." 

If prop is not found, return an error with the message,
"Could not find property."
`

// Data
const users = [
  {
    "login": "knuth",
    "firstName": "Donald",
    "lastName": "Knuth",
    "likes": ["C", "Unix"]
  },
  {
    "login": "norvig",
    "firstName": "Peter",
    "lastName": "Norvig",
    "likes": ["AI", "Search", "NASA", "Mars"]
  },
  {
    "login": "mfowler",
    "firstName": "Martin",
    "lastName": "Fowler",
    "likes": ["Design Patterns", "Refactoring"]
  },
  {
    "login": "kent",
    "firstName": "Kent",
    "lastName": "Beck",
    "likes": ["TDD", "wikis", "Design Patterns"]
  }
];


// lookup()
const lookup = (login, prop) => {
// Only change code below this line

// Only change code above this line
};



// Tests
test('lookup() likes', assert => {
  const msg = `lookup(<login>, 'likes') should return likes
    for the specified user.`;

  const actual = lookup('norvig', 'likes');
  const expected = ["AI", "Search", "NASA", "Mars"];

  assert.deepEqual(actual, expected, msg);
  assert.end();
});


test('lookup() last name', assert => {
  const msg = `lookup(<login>, 'lastName') should return the last name
     for the specified user.`;

  const actual = lookup('knuth', 'lastName');
  const expected = 'Knuth';

  assert.deepEqual(actual, expected, msg);
  assert.end();
});


test('lookup() with unknown user', assert => {
  const msg = `lookup() with unknown user should return an error
    with the correct message.`;

  const value = lookup('nobody', 'likes');

  const actual = value.message;
  const expected = 'Could not find user.';

  assert.equal(actual, expected, msg);
  assert.end();
});


test('lookup() with unknown property', assert => {
  const msg = `lookup() with unknown property should return an error
    with the correct message`;

  const value = lookup('mfowler', 'noprop');

  const actual = value.message;
  const expected = 'Could not find property.';

  assert.equal(actual, expected, msg);
  assert.end();
});

              
            
!
999px

Console