When working with two HTML datalists, I extract their input values to query a JSON file. Initially, I search for the keys in my JSON file, which represent college majors, with their corresponding values being the courses. By matching the object key with the program input, I can retrieve the desired element. The next step involves finding the course within that program by concatenating the program and course number inputs. However, this step becomes problematic when dealing with programs that contain spaces in their names, like "I S". The concatenation operation seems to affect the encoding of the strings, leading to discrepancies in comparisons.
During the first step of the process, where the program courses are successfully retrieved, the issue arises in the second step when trying to match the course name within a program that has spaces in its name. The concatenation of the program and course variables seems to alter the encoding of the resulting string, causing the comparison to fail. While accessing the properties of the program element is successful, trying to match the concatenated string with the children of the objectkey value proves to be problematic.
To further illustrate the problem, the console output of the program encoding shows differences when concatenated with course numbers, especially in cases where the program name contains spaces. The encoding discrepancies hinder the successful comparison of the concatenated string with the properties of the program's children, creating a challenge in accurately retrieving the desired course information.
Summary of the Issue
This issue highlights the challenges faced when trying to concatenate and compare strings within a JSON file, particularly when dealing with variable encoding formats. The discrepancies in string encoding result in failed comparisons and hinder the accurate retrieval of course information within specific programs.