while() loop runs indefinitely; the condition won’t change; .replace() doesn’t work as expected [duplicate]

This question already has an answer here: Replace method doesn't work 4 answers I am trying to replace a letter with a white space ” ” inside a word using the following JS code: let letter = document.querySelector(“#letter”).value.toLowerCase(); var word = “letters”; var i = word.indexOf(letter); console.log(“word[i]: ” + word[i]); while(i > -1) { console.log(i);…

Details

Laravel store user ip

I want store user ip when register: use Illuminate\Http\Request; public function register(Request $request) { $validator = Validator::make($request->all(), [ ‘name’ => ‘required|string’, ‘phone’ => ‘required|numeric|digits:11’ ]); if ($validator->fails()) { return response()->json([‘error’=>$validator->errors()], 200); } $user = Agent::where(‘phone’, $request->phone)->where(‘verified’, 1)->first(); if($user){ return response()->json([‘success’=> ‘Agent already exists’], 204); } else { $user = Agent::where(‘phone’, $request->phone)->first(); $input = $request->all(); $input[‘type’]…

Details

Java: Can I initialize a function directly without converting it to a variable?

For the first code: findContact(String name) did not return any contact rather it returned “Error in finding contact”). FIRST CODE DID NOT WORK: public Contacts findContact(String name) { for (int i = 0; i < contactsArray.size(); i++) { if (contactsArray.get(i).getName().equals(name)) { // USED IT DIRECTLY return contactsArray.get(i); } else { System.out.println(“Error in finding contact”); }…

Details