Skip to content
Advertisement

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

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

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

Advertisement