A function that always evaluates to the same result value given the same argument value(s) and that does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices.
Questions tagged [pure-function]
124 questions
0
votes
1 answer
In Java, would all these methods be considered pure functions?
This program determines whether the string the user has input is a palindrome or not.
import acm.program.ConsoleProgram;
public class PurePalindrome extends ConsoleProgram {
public void run() {
String originalString;
String reversedString;
…

user3053240
- 33
- 1
- 6
-1
votes
2 answers
Using pure function (For Each) to change array, failing Jest
I am trying to use a pure function that is using For Each, the function will change input array to return 'x'. Can someone help me explain why I am getting this error?
Functions:
let functions = {
helper: (x) => {
return x;
},
…

waterMelon
- 15
- 5
-1
votes
1 answer
For loop pure function jest test using expect... cannot read property
I am trying to make a pure function using a for loop pass a jest test/npm test in the terminal... I am getting an error that it cannot read the property of toBe...
My function:
const syntax = {
for1: (a,b) => {
for(let a=1; a<10; a++){
…

waterMelon
- 15
- 5
-1
votes
1 answer
What is the difference between happening of event on element and emiiting an event from element in dom?
I want to understand when I click a dom element, then click event happens on that element and associated event-handler function is called. This is a basic example of an asynchronous function.
My question is related to implementations behind…

Suraj Prakash Joshi
- 211
- 2
- 10