Example: Now when i invoke it, let’s say i want to put 2 values into 2nd parameter; exampleFunq(1, 2 3) i know this code is wrong but is it a possible concept? Answer JavaScript doesn’t have tuples as language concept, but you can always pass an array or an object: Using destructuring, you can make this seamless, if so desired:
Tag: function
Can a some() function replace nested forEach()?
I need to replace two (nested) forEach loops with a some function. The purpose of the code block is to check if the [1] elements in arrayOne are within the max & min of arrayTwo. The code currently works fine and looks like this: Let me know if it isn’t clear enough. Really appreciate your help. Answer Yes, you can
Calculation based on variable containing multiple possible substrings
I have 2 variables (source and platform) that has results such as: “Source”: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44 etc. “Platform”: Win32 etc. I want to create 2 new variables (device and system), “extracted” from the above ones. I found some code, but I don’t know how to implement it in spss syntax
Why is my decryption function not working?
I created a function to encrypt and decrypt messages. the encrypting works fine. but when I try to log encrypted Hello World! it just logs H. Fixed it, i edited the encoding system to place a – between chars and the decoding system to just split the message at – and check if the element starts with c n or
A function that works on an HTML page but not on the other one
I have a problem with the snippet below : everything works perfectly when I press the button on the 1st page. But it tells me that “secondPageItems” is not defined when I press the button on the 2nd page. (here every thing works fine because it’s on the same HTML page) Even stranger, if I put “secondPageItems” and “secondPageHiden” above
Set variable to method
I want to make a shorthand library for myself, ex: shortening querySelector to get. would there be a way to return just the method without document? EXAMPLE: Thanks. Answer You have to call .querySelector on either the document or an element. It can’t be left off. While you could pass it into the function… Having to write document each time
Arrow function that expects 2 numbers and returns undefined if they aren’t numbers
Need help. Need an arrow function that expects 2 numbers as input (e.g. 1, 2) and returns the sum of the two numbers. If anything other than 2 numbers is passed, return undefined. Not sure where I’m going wrong on this. Just keeps returning undefined, and doesn’t go to finding sum. Answer Use isNaN
Sudoku Validator is not returning correct boolean
I’m writing a sudoku validator and I’ve run into a problem at the very end of it. I’m very new to coding, so please be patient with me. The function sudokuIsValid is supposed to take a puzzle (an array of 9 arrays) and check each column, row, and 3×3 grid to see if it is valid. The function includes1To9 works
How do you use several variables and get several answers from one function in JavaScript?
I’ve been learning JavaScript for a college assignment and I can’t figure out why my point counters don’t work. I tried making a different program to figure out why at it seems that when I try to make the function availible for several variables, it stops working. Now this only allows itself to be added to once. Any and all
Javascript join multiple arrays with & but I get duplicates
I have this project in which I create a link with multiple arrays that are joined with & signs. It works perfectly, but when I get more than 3 arrays, it doesn’t. When I skip a couple of questions I get a & sign at the beginning of the string and when I only choose the first it adds one