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?
- What’s the difference between “{}” and “[]” while declaring a JavaScript array?
- For-each over an array in JavaScript
- How to append something to an array?
- Sorting an array of objects by property values
- How do I check if an array includes a value in JavaScript?
- Loop through an array in JavaScript
- How to split a string into an array in Bash?
- 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
- How can I access and process nested objects, arrays or JSON?
- Converting array to list in Java
- What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
- Split string into array
- 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++
- TypeScript Objects as Dictionary types as in C#
- Data type not understood while creating a NumPy array
- Copy array by value
- How can I reverse an array in JavaScript without using libraries?
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- What is the way of declaring an array in JavaScript?
- How to create an associative array in JavaScript literal notation
- Are vectors passed to functions by value or by reference in C++
- How do I declare a 2d array in C++ using new?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- Remove duplicate values from JS array [duplicate]
- 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
- Getting “conflicting types for function” in C, why?
- 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
- Form submission: PHP S_SESSION statements within a foreach loop
- How to filter an array/object by checking multiple values
- How to split a string into an array in Bash?
- How do you check if a variable is an array in JavaScript?
- Working with a List of Lists in Java
- Array Size (Length) in C#
- Getting “conflicting types for function” in C, why?
- How do I empty an array in JavaScript?
- How to find the sum of an array of numbers
- How to convert jsonString to JSONObject in Java
- Array of arrays (Python/NumPy)
- Remove Object from Array using JavaScript
- Short circuit Array.forEach like calling break
- Remove duplicate values from JS array
- How to check if array is empty or does not exist?
- My javascript is returning this error: $.ajax is not a function
- Why is using “for…in” for array iteration a bad idea?
- what does “>>>” mean in java?
- How to convert List
to int[] 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
- Filter array to have unique values
- How to randomize (shuffle) a JavaScript array?
- 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?
- Correct way of looping through C++ arrays
- When will the worst case of Merge Sort occur?
- 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 to print elements from array with javascript
- 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?
- What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
- Short circuit Array.forEach like calling break
- Short circuit Array.forEach like calling break
- Most efficient way to convert an HTMLCollection to an Array
- ow to create a histogram in java
- How to remove item from array by value?
- what does .space do in mips?
- Get all unique values in a JavaScript array (remove duplicates)
- How do I remove an array item in TypeScript?
- How to handle ETIMEDOUT error?
- What does << mean in Ruby?
- Uncaught Typeerror: cannot read property ‘innerHTML’ of null
- Remove duplicate values from JS array
- How to loop through an array containing objects and access their properties
- 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