Skip to main content

All Questions

0 votes
2 answers
40 views

Utilizing array items as an entire case in a switch statement

I would like to generate cases in a switch statement from an array. Here is how the array is generated: pointObjects = []; for (var i = 0; i < 2; i++) { // Generate cases. var url; var ...
throwaway2908457's user avatar
-2 votes
1 answer
103 views

How can I add the chained calculation functionality in a JS calculator, i.e. calculating with the previous result

I am building a JavaScript Calculator as an exercise of TheOdinProject. I am facing problems in chained equations as my calculator is giving wrong results. How can I calculate the result as the value ...
imkrishnasarathi's user avatar
-1 votes
1 answer
84 views

Is there a way to print error message when a user presses the "enter" key instead of throwing an exception or a primitive type error(char to str)?

I am currently working on a project in my first Java class. I am writing a program for a mock company that allows for various user inputs depending on user need for animal registration. The info ...
K_B's user avatar
  • 33
0 votes
5 answers
107 views

Can we compare a user Input with an array? If yes then what wrong am I doing? [closed]

The pitch of the code shows an error! public static void switchTest() { String[] cars = {"TATA", "BMW", "Hero", "Honda", "Bajaj", "Yamaha&...
DIPTENU SARKAR's user avatar
0 votes
0 answers
23 views

InnerHTML not working to display array text [duplicate]

I am trying to make case 3 display array as text in the innerHTML. For some reason its not working, the array is a string already, I converted it using a .join() method. let userList = ["Sarah", "...
Learning Smart's user avatar
0 votes
2 answers
74 views

How to add prompt input value to array after switch statement?

I have created an array with 10 names hard coded in as an existing database. I am struggling to get the user input value from the prompt of option 1 and push it to the array. let userList = ["...
Learning Smart's user avatar
1 vote
1 answer
39 views

How do I fix a default error on my switch statement?

So, I have to make a program that shows a menu of a bank, with several options for the user to input. For an input G, the user enters a deposit, which is stored inside an array. For an input S, it ...
RedPumpkin's user avatar
1 vote
1 answer
59 views

Why isn't the background colour changing? (JS)

I'm new to programming, and stackoverflow, so I apologize if my question isn't in the correct format. I'm working with code which was partially written by my professor, with directions included from ...
Shaun J's user avatar
  • 11
0 votes
1 answer
2k views

Error - PHP Warning: Undefined array key "gid"

Does anyone know how to fix this error, please? PHP Warning: Undefined array key "gid" in /index.php [index.php] $gid = ['1245620']; $mid = ['0111161]; $sid = ['0108778]; switch($_GET['gid'...
user avatar
0 votes
1 answer
464 views

C# Console Application project to compute the total price of a transaction

I cannot take multiple inputs from the user, calculate them, and show them on screen. There is also a scene card option for discount.If they have Scene card with them, the base price should be reduced ...
user15610976's user avatar
0 votes
1 answer
76 views

Javascript switch case keeps skipping to the default case

My Switch case keeps on going to default. The condition is from the intersectionWord which outputs a specific keyword from an array which matches up to a word in the trigger word array aka an ...
onaikepo's user avatar
-2 votes
1 answer
52 views

Is there a way to compare the strings in two arrays to see if one of them is present within the other

I have two arrays. First one: const triggerWord = ["what", "how", "where", "who", "can"]; Second one: const myArray = query.split(" "); - it ...
onaikepo's user avatar
-1 votes
1 answer
47 views

Java loop not working because of wrong scanner usage [duplicate]

I'm making a text editor in java. I'm using a switch to create a menu. One of the options of the menu is to insert lines to the existing array where i need to make a loop to add strings to an array ...
Its_JC's user avatar
  • 3
0 votes
2 answers
300 views

How to display different data if a switch is toggled in React-Native

I'm trying to make a donut chart that shows different values. But if the switch on the screen it toggled, I want it to display a different set of values. All the data is currently stored in an array I ...
PikachuUsedSplash's user avatar
0 votes
3 answers
56 views

For loop is not returning a different value for every array index

I've written a code about a program where a word gets encrypted as a number dependent on a fixed parameter such as "Software" turning into 76389273. However the for loop is not returning ...
kelkrekeksa's user avatar

15 30 50 per page
1
2 3 4 5
31