Issue running test in findKey

Hi there! I’m working on “Re-creating the Lodash Library” project and I’m running into a strange issue when I attempt to run the test for findKey. Below I have included all the code that I have currently added. When I attempt to run the test, I get this message from the terminal:


const startsWithV = string => string.startsWith('v');

TypeError: Cannot read property 'startsWith' of undefined
    at startsWithV (/home/ccuser/workspace/underscore-javas
    at Object.findKey (/home/ccuser/workspace/underscore-ja
    at Object.<anonymous> (/home/ccuser/workspace/underscor
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)

I double-checked my code with the project walkthrough video and I believe I recreated it exactly. The issue seems to be in the find-key.js test file, yet for the life of me, I can’t seem to figure it out. Any help would be greatly appreciated! Thanks! :sunglasses:

const _ = {
  clamp(num, lowerBound, upperBound) {
    let clampedNum = Math.max(num, lowerBound);
    clampedNum = Math.min(clampedNum, upperBound);
    return clampedNum;
  inRange(n, start, end) {
    if (end === undefined) {
      end = start;
      start = 0;
      if (end < start) {
        let tempValue = 0;
        tempValue = end;
        end = start;
        start = tempValue;
    let isInRange = (n >= start && n < end);
    return isInRange;
  words(string) {
    const arr = string.split(' ');
    return arr;
  pad(string, length) {
    if (string.length >= length) {
      return string;
    let startPad = Math.floor((length - string.length) / 2);
    let endPad = length - string.length - startPad;
    let paddedString = ' '.repeat(startPad).concat(string.concat(' '.repeat(endPad)));
    return paddedString
  has(object, key) {
    let hasValue = false;
    hasValue = object[key] !== undefined;
    return hasValue;
  invert(object) {
    let invertedObject = {};
    for (let key in object){
      let originalValue = object[key]
      invertedObject[originalValue] = key
    return invertedObject
  findKey(object, predicate){
    for (let key in object){
      let value = predicate[key];
      let predicateReturnValue = predicate(value);
      if (predicateReturnValue){
        return key;
    return undefined;

// Do not write or modify code below this line.
module.exports = _;

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.