The error is here:
hasLetter("a",words[]);
You are passing the first item of words
, instead of the array.
Instead, pass the array to the function:
hasLetter("a",words);
Problem solved!
Here’s a breakdown of what the problem was:
I’m guessing in your browser (chrome throws a different error), words[] == words[0]
, so when you call hasLetter("a",words[]);
, you are actually calling hasLetter("a",words[0]);
. So, in essence, you are passing the first item of words to your function, not the array as a whole.
Of course, because words
is just an empty array, words[0]
is undefined
. Therefore, your function call is actually:
hasLetter("a", undefined);
which means that, when you try to access d[ascii]
, you are actually trying to access undefined[0]
, hence the error.
Related Posts:
- Javascript Uncaught TypeError: Cannot read property ‘0’ of undefined
- Does JavaScript have a method like “range()” to generate a range within the supplied bounds?
- Does JavaScript have a method like “range()” to generate a range within the supplied bounds?
- Create an empty object in JavaScript with {} or new Object()?
- Checking if a key exists in a JavaScript object?
- For-each over an array in JavaScript
- Sorting an array of objects by property values
- Loop through an array in JavaScript
- Loop through an array in JavaScript
- How can I remove a specific item from an array?
- Find object by id in an array of JavaScript objects
- Converting array to list in Java
- Java Error “Exception in thread “main” java.util.InputMismatchException” On an Array program
- How can I remove a specific item from an array?
- Array.size() vs Array.length
- Sort array of objects by string property value
- How to print elements in a vector c++
- Data type not understood while creating a NumPy array
- What is the way of declaring an array in JavaScript?
- Are vectors passed to functions by value or by reference in C++
- How do I declare a 2d array in C++ using new?
- Remove duplicate values from JS array [duplicate]
- How to loop through an array containing objects and access their properties
- Get the last item in an array
- How do I empty an array in JavaScript?
- Remove duplicate values from JS array
- How can I create a two dimensional array in JavaScript?
- How to loop through an array containing objects and access their properties
- Get the last item in an array
- How to split a string into an array in Bash?
- How do you check if a variable is an array in JavaScript?
- Array of arrays (Python/NumPy)
- Short circuit Array.forEach like calling break
- Why is using “for…in” for array iteration a bad idea?
- what does “>>>” mean in java?
- What’s the source of Error: getaddrinfo EAI_AGAIN?
- Calculating Standard Deviation & Variance in C++
- Deleting array elements in JavaScript – delete vs splice
- How to compare arrays in JavaScript?
- Better way to sum a property value in an array
- How to convert int[] into List
in Java? - What is a list in Bash?
- What does ** do in C language?
- In Java, how to append a string more efficiently?
- How to convert an Object {} to an Array [] of key-value pairs in JavaScript
- Fastest way to duplicate an array in JavaScript – slice vs. ‘for’ loop
- Merge/flatten an array of arrays
- How do I create an array of strings in C?
- Remove Object from Array using JavaScript
- What is the difference between ( for… in ) and ( for… of ) statements?
- Short circuit Array.forEach like calling break
- Most efficient way to convert an HTMLCollection to an Array
- How to remove item from array by value?
- How do I remove an array item in TypeScript?
- How to handle ETIMEDOUT error?
- What does << mean in Ruby?
- Remove duplicate values from JS array
- How to create an array of strings in C?
- Sorting arrays in javascript by object key value
- Initialization from incompatible pointer type warning when assigning to a pointer
- Bubble sort algorithm in MIPS
- How do I check whether an array contains a string in TypeScript?
- How do you put an image file in a json object?
- Error: unsupported use of matrix or array for column indexing
- Remove last item from array
- Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array
- Using multiple variables in a for loop in Python
- Objects are not valid as a React child. If you meant to render a collection of children, use an array instead
- type any? has no subscript members
- Simple average function in Javascript
- Java ArrayList for integers
- java.lang.ArrayIndexOutOfBoundsException: 4 Error
- IndexError: index 10 is out of bounds for axis 0 with size 10
- Checking for duplicate strings in JavaScript array
- How to remove all duplicates from an array of objects?
- Finding the average of an array using JS
- Is there a simple way to make a random selection from an array in JavaScript or any other programming language?
- How to sort an array in Bash
- Uncaught TypeError: Cannot read property ‘toUpperCase’ of undefined
- Most efficient method to groupby on an array of objects
- How can I find the number of elements in an array?
- Array type char[] is not assignable
- Convert array to JSON
- Two-dimensional array in Swift
- How to get the first element of an array?
- C char array initialization
- JavaScript array to CSV
- console.log showing contents of array object
- console.log showing contents of array object
- How to sort 2 dimensional array by column value?
- Difference between char *argv[] and char **argv for the second argument to main()
- Array to Hash Ruby
- How do I store an array in localStorage?
- Java says this method has a constructor name
- GCC: Array type has incomplete element type
- javascript push multidimensional array
- variably modified array at file scope in C
- Numpy matrix to array
- Using the Pythagorean theorem with Java
- “Uncaught TypeError: Illegal invocation” in Chrome