The 170,000 item array is experiencing processing errors

I have created a JSFiddle containing a small word list of two and three-letter words. These words are loaded into an array and then filtered using the Array.prototype.filter method, which is functioning correctly.

However, when my page attempts to download the Enable1 word list commonly used in games featuring word lists, my filter function returns an empty array instead of the expected 105 words.

I have verified that:

  • The word lists both start with the word "aa" as intended
  • The lists contain 1091 and 172820 words respectively
  • All words are lowercase and do not include surrounding spaces
  • Upon loading, the only filtering criteria is "has exactly two letters"
  • No errors appear in the console
  • There is a 100mb (25%) increase in the Fiddle page's RAM usage, but my system still has 35% of RAM available

The provided code snippet shows the structure of my program. Why is this issue occurring? How can I ensure it functions properly with the larger word list?

Answer №1

It appears that the issue lies in how you are splitting the result of your ajax call. Upon logging the array obtained from the split response, anomalies like "aa\r" can be seen.

To rectify this, consider using:

app.words(data.contents.split("\r\n"));

Instead of:

app.words(data.contents.split("\n"));

Implementing this change should lead to an improved outcome.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the reason for requiring this to be passed as an Array instead of a String?

I'm currently learning node.js through a tutorial in a book titled Node Web Developments. Issue: I am struggling with understanding why an array [] is being passed as the 3rd argument from mult-node.js to the required function htutil.page(), instead ...

Merge three asynchronous tasks into a single observable stream

I have 3 different observables that I am using to filter the HTML content. Here is the TypeScript code snippet: fiscalYear$ = this.store$.select(this.tableStoreService.getFiscalYear); isLoading$ = this.store$.select(this.tableStoreService.tableSelector ...

Retrieving data from an external PHP script

I'm facing an issue with retrieving results from a PHP file after submitting a form: index.php (located at ) <form id='loginForm' action='http://domain1.com/mail.php' method='POST'> <input id=&apo ...

How can Sequelize handle multiple foreign keys - whether it be for one-to-many relationships or many-to-many relationships

I'm working on a project with two tables: users and alerts. Users should have the ability to upvote and downvote on alerts. Here are the model definitions: Alert module.exports = function(sequelize, DataTypes) { var Alert = sequelize.define("al ...

Configuration object for Webpack is not valid

I encountered an error while using webpack that says: Invalid configuration object. Webpack has been initialized with a configuration object that does not conform to the API schema. - configuration.resolve has an unknown property 'extension&ap ...

Selecting list items using the up and down keys in JavaScript/jQuery

As the search terms dynamically populate a list of items, I am looking for a way to make the list items selectable/focused using the up/down keys and hide the dropdown with ESC key. <form> <div> <div class="field"> & ...

What is the best way to create a sharp light effect on a sphere in three.js?

My three.js scene features a sphere and directional light. The sphere appears to gradually darken as you look at it. How can I speed up the transition from light to dark? Is there a way to make the light appear "sharper"? var scene, camera, renderer, co ...

Exploring new options to deduct time from Kendo UI timepickers without relying on Javascript

My current project involves an Asp.net MVC 4 application that includes a Time entry screen. This screen utilizes various Kendo controls and Razor Html helpers to enhance the user experience, such as: @(Html.Kendo().TimePickerFor(m => m.StartTime).Name( ...

Retrieving JSONP using PHP does not yield results, only an object

Received JSONP response from an external domain: jQuery183012824459988766945_1354016515353([{"ID":"X1122","LName":"Smith","FName":"John"},{"ID":"X770","LName":"Johnson","FName":"Amy"}, {"ID":"X994", "LName": "Williams", "FName": "David"}, {"ID": "X580" , ...

What is the best way to transform an array into valid JSON format?

Looking to reformat my array in JSON form product[0]['product_id'] product[0]['name'] .... product[1]['product_id'] product[1]['name'] ... After using JSON.stringify(), the output is as follows: {"0":{"product_id" ...

Ensure that the v-for attribute has an increased value

Is there a way to have an incremented value in this code snippet? :data-value="Math.round(elecs[index].obtenus/elecs[index].maxsiege*100) Here is my attempt at iteration : :data-value="Math.round(result += elecs[index].obtenus/elecs[index].maxsiege*100 ...

Grid functionality in Bootstrap not responsive on mobile devices

I have created a grid structure for my website using bootstrap 3. It looks great on desktop, but when I resize the window it does not switch to mobile or tablet view. What am I doing wrong? On desktop, I want each panel to take up 1/6 of the row, and on ...

Which is the better choice for me - webpack or create-react-app?

What's the best way to kickstart my react app - webpack or create-react-app? Are there any benefits to using webpack instead of create-react-app? ...

Illustrator export script for efficient saving of images as web-friendly jpg files

Looking for assistance with creating a script in illustrator CC2017 that can automatically export files to web (legacy) as JPG, save the file, and then close it. I have 700 files, each with 2 art boards, and manually exporting and saving each one is time ...

AngularJS: Modifying values in one div updates data in all other divs

The webpage appears as shown below: https://i.sstatic.net/IxcnK.png HTML <li class="list-group-item" ng-repeat="eachData in lstRepositoryData"> <div class="ember-view"> <div class="github-connection overflow-hidden shadow-oute ...

Find the object in the array that has a name that is a combination of

I am facing an issue in implementing TypeScript validation for filtering an array. I have a specific array of actions and I want to filter out internal actions from it. Despite my efforts, I am unable to properly communicate to TypeScript that the filtered ...

The insertMany method in Nodejs does not function properly with the Mongodb ordered option

I have integrated MongoDB into my application, specifically version 4.4.1. I made sure to set the unique option in the word field to true for data integrity. Here is the code snippet I am using: try { const words = [ { word: "her" }, ...

Validation in AngularJS - Setting minimum length for textarea using ng-minlength

I am currently tackling a project that heavily relies on AngularJS for the front-end. Here's what I am dealing with: The validation requirement I am aiming for is as follows: The Next button should remain disabled unless the reason provided is at le ...

Trouble with setting up sub sections in VueJS

Currently, I am developing a vuejs application that involves creating sections and subsections. I encountered an issue when attempting to add a subsection, as it resulted in an error message: Uncaught TypeError: sections[1] is undefined Here's a gli ...

Adaptable Collection of 4 Images

I am facing a challenge in replicating eBay's 'Today' featured seller layout with 4 square images creating one box (refer to the image). I am using Bootstrap for this task, and I am finding it difficult to comprehend how to achieve this. I h ...