.Understand the Differences Between import and require

Tell us what’s happening:

I am unable to catch the problem with my code.
Getting the error: Cannot read property ‘capitalizeString’ of undefined
Please Help!!

Your code so far


"use strict";
import { capitalizeString } from "./string_functions"
capitalizeString("hello!");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/understand-the-differences-between-import-and-require

You almost got it :smiley: The problem is in your path file where you are trying to import the capitalizeString function. Since the test states that what you need to import is in the same directory that you are working in, you don’t need ./ in the pathname, just the file name itself.

Thanks, That works :slight_smile:

1 Like