Skip to main content
Filter by
Sorted by
Tagged with
-4 votes
3 answers
105 views

I wrote the algorithm below and asked an AI to evaluate my solution. //TESTS: console.log(firstNonRepeatingCharacter('abacabaz')) //c console.log(firstNonRepeatingCharacter('aabbccdeefgghijj')) //d ...
claudiopb's user avatar
  • 1,094
1 vote
1 answer
127 views

I hope this is not a silly question. Why when I use for (let property in myObject)... property is recognized by typescript as "string" instead of "keyof typeof myObject"? Is there ...
Daniel Cruz's user avatar
  • 2,429
-2 votes
1 answer
39 views

I'm new to React. I know that comments should be received as an object, so I tried using a for...in loop to iterate over them. However, when I attempted to use the for...in loop, I encountered an ...
Dipesh's user avatar
  • 17
1 vote
1 answer
224 views

import SwiftUI import MapKit import CoreLocation struct ContentView: View { @State private var position: MapCameraPosition = .userLocation(fallback: .automatic) @State private var hazards: [(...
Jacklan's user avatar
  • 11
0 votes
1 answer
41 views

Still learning JS and confused over this The below code gives out undefined as output when it should be "v" - am I missing something or using for-in over a string is the issue let s="...
shivansh sharma's user avatar
0 votes
3 answers
71 views

I tried looping names of front-end developers nested inside of objects(refer to code) and when I printed it to console it says display is not defined. var employees = { sales: { ...
huz3y's user avatar
  • 21
-3 votes
3 answers
146 views

I'm new to JavaScript and am learning about for...in loops and objects right now. I'm practicing with the following example: let spaceship = { crew: { captain: { name: 'Lily', ...
Will Barrett's user avatar
0 votes
1 answer
87 views

I'm new to rust and i'm building an implementation of the grep command to learn this language. I'm trying to create a function to match the search query in a case insensitive way, but i'm having ...
Alex Licata's user avatar
0 votes
2 answers
94 views

I've a dataset of firms with year from 1960-1989 and month (1-12) that looks like this. PERMNO. Year Month 10057 1960 1 10057 1960 2 10057 1960 3 10057 1960 4 10057 1960 5 10057 1960 6 10057 1960 7 ...
Jingy's user avatar
  • 1
0 votes
1 answer
45 views

I have a object named user where one of the properties is skills and im trying to find a user who have the maximum no. of skills. let maximum = 0; let name; for (const user in users) { const len = ...
s-chuck's user avatar
  • 33
0 votes
1 answer
892 views

I try to do iteration on object on nodejs using for in, on my local it's working just fine. but when i deploy it to web service, it pass an error. but when i tried on my local it work just fine const ...
Muzani Pamasarsa's user avatar
0 votes
3 answers
416 views

As part of a practice challenge for a bootcamp, I've been asked to: 'Fix the jumbled string values - replace them all with versions that are all lowercase' I've tried several approaches based on ...
maximusmd's user avatar
0 votes
2 answers
250 views

Asked to: 'Iterate through the staff nested inside the restaurant object, and add their names to the staffNames array.' My solution keeps getting rejected with this error: 'Use a declaration keyword ...
maximusmd's user avatar
1 vote
1 answer
52 views

something is bugging me at the moment about For In Loops. I understand how to use them but what I can't seem to get my head around is.. Well, in this example: const tree = { name: 'Oak', ...
James's user avatar
  • 127
2 votes
3 answers
348 views

I am confused with the following code. func allTestsPassed(tests: [Bool]) -> Bool { for test in tests { if test == false { return false } } return true } If ...
Ryu Hiroyama's user avatar
1 vote
1 answer
958 views

I am wondering what's going on behind the scenes in for...in vs. for...of loops in JavaScript. I accidentally switched them up on two similar instances, where one worked and one didn't, and I'm trying ...
user53's user avatar
  • 21
0 votes
0 answers
34 views

HI i am practicing resume creator app using JavaScript. i wanted to take all user inputs using gelements by id method in a loop. when i am trying getting error of null regarding value property without ...
Sairam Gudiputi's user avatar
0 votes
2 answers
197 views

I wonder how do I get the sum of some elements in an array? for example, here's my array and I only need to sum up the first 5 elements: var num = [31, 28, 31, 30, 30, 31, 30, 31, 30, 29, 31, 31] I ...
daria's user avatar
  • 11
-1 votes
1 answer
105 views

a = [1,2,3] for num in a: a = a + [num] print(a) >>>[1,2,3,1,2,3] a = [1,2,3] for num in a: a += [num] print(a) >>> The first code works as expected, so I assume the below ...
JWw's user avatar
  • 3
0 votes
1 answer
47 views

Array.prototype.myMap = function(callback) { const newArray = []; // Only change code below this line for(let i in this){ newArray.push(callback(this[i], i, this)) } // Only change code ...
user21100284's user avatar
1 vote
2 answers
144 views

I'm trying to solve a problem where a for in range loop goes over a sentence and capitalises every letter following a ".", a "!" and a "?" as well as the first letter of ...
chonk1234's user avatar
0 votes
2 answers
109 views

I have a string and I want to retrieve all the characters with maximum occurring frequency. I have created a function that returns a single maximum frequency character in the string. But how to modify ...
Apoorv Sharma's user avatar
1 vote
0 answers
98 views

I'm trying to substitute tables with JS Data Grids in my templates by using https://www.ag-grid.com/javascript-data-grid/getting-started/ . When I copy-paste the example from above website, the data ...
George Pt's user avatar
0 votes
1 answer
293 views

I am running a piece of JQ filter code. This is been run on a Windows Server 2016 with GIT BASH. the code looks like the following: (don't mind the echo's and echo $i, this is for verbose reasons) ...
Randy's user avatar
  • 13
1 vote
2 answers
172 views

I am trying to make a basic notes app using JS. I am storing notes in localStorage, and I am trying to print those notes using for-in loop. It works mostly fine, but I don’t know why I am getting ...
user avatar
0 votes
1 answer
49 views

I've got a list of object which after looping I'm trying to sort the final list by given ISO8601 format favouriteDateTime: 2022-12-16T10:46:55.551Z. There are mutiple sorting method but which one to ...
Digamber negi's user avatar
0 votes
0 answers
48 views

I have a map that looks like this: stuff = { object-1 = { id = "1" main_value = "blue" additional_in_values = ["red"] ...
rpc's user avatar
  • 97
1 vote
1 answer
773 views

I thought this would be easy :frowning: Goal is to transform this map: ``` accounts = { "acct-key-1" = { "billingcode" = "sys" "future-key" = "...
rpc's user avatar
  • 97
-1 votes
1 answer
113 views

print the numbers between this two numbers let a=[5,7]; var temp=[]; for(var i=5;i<=8;i++){ `temp.push(i);` } console.log(temp);=> in this i got all elements[5,6,7,8] but i need only ...
slystersanto's user avatar
0 votes
1 answer
162 views

As the MDN website says "for...in is most practically used for debugging purposes", which I also am doing. Is there any other way to get the same results instead of using for ... in to get ...
John's user avatar
  • 606
1 vote
1 answer
72 views

For example, we can replace “a” or “A” with @ and get “с@t” instead of “cat”. Letters to replace: a - @; i - 1; s - $; o - 0; t - + Using a for-in or forEach() methods. I used this option but it's ...
Ihor Niemyi's user avatar
0 votes
3 answers
1k views

I'm trying to iterate over a list and change its values with a "for in" loop: example_string = "This is a string." for char in example_string : char = 'r' example_list = list(...
Aelian's user avatar
  • 23
0 votes
2 answers
60 views

I am trying to print out a set of students in a class in a numbered list. Here's the code I have var spanish101: Set = ["Angela", "Declan", "Aldany", "Alex", &...
Brianna's user avatar
0 votes
4 answers
940 views

I want to show the first positive number in the array in the console blog, but according to my code, it displays the second one, which is 6. Please provide an answer to my problem and give an explain ...
Arin Avanusyan's user avatar
0 votes
1 answer
90 views

I'm doing a codewars challenge that checks if Sudoku grid is valid. https://www.codewars.com/kata/529bf0e9bdf7657179000008/train/javascript It returns false if there are duplicate values in 1) ...
Julian's user avatar
  • 441
-2 votes
1 answer
114 views

Please note: This question is purely hypothetical and for learning purposes. I do not plan on making unnecessary micro-optimizations. From research that I've done, it seems that using for-in loops are ...
WillWillington's user avatar
1 vote
3 answers
637 views

I'm trying to return the sum of all transactions but the program isn't returning the sum question Define a function, totalTransactions, that takes an array of objects called transactions. ...
Mist's user avatar
  • 37
0 votes
0 answers
774 views

Sending put http call with express js. While using typescript and trying to iterate through the object, I'm getting an error "Type 'any' is not assignable to type 'never'" let i: keyof ...
Anastasiya Litvinenka's user avatar
-1 votes
1 answer
93 views

I need to restart the loop every time the if statement occurs so that the correct roman numeral conversion works by pushing the key(roman numeral) of the iterator to counter, and by subtracting the ...
Lachlan's user avatar
0 votes
1 answer
94 views

let obj = { a:10, b:20, c:true, d:null } for(let key in obj) { //console.log(key); //console.log(obj.key); //4 undefined console.log(obj[key]) // 10 20 true null //work } why dot ...
Max Joy's user avatar
0 votes
0 answers
49 views

In Swift , the following code works well var arr = [1, 2,3 ,4, 5, 6] for num in arr{ arr.removeAll { val in return val == num } } ...
DNG's user avatar
  • 649
0 votes
2 answers
146 views

/* Write each function according to the instructions. When a function's parameters reference `cart`, it references an object that looks like the one that follows. { "Gold Round ...
Mahjur's user avatar
  • 3
-1 votes
1 answer
342 views

Map Characters & Sum Ended Description You are given a number stored in a variable with the nameN You are also, given a string, whose length is stored in a variable with the nameK, and the string ...
Hemant Pratap Singh's user avatar
0 votes
1 answer
2k views

as u can see below , obj.key outside the for in loop is working properly but why not in the for in loop ? and obj[key] inside the for in loop is working properly , what`s the reason behind one is ...
lucky's user avatar
  • 31
-1 votes
1 answer
43 views

**I want to set the background of all objects of the .false class back to the default color before i change the correct class to green ** let objects = document.querySelectorAll('.false'); ...
Philip F's user avatar
-1 votes
2 answers
53 views

Is anyone can help me to found this output. Sample output: ['milk', 'bread', 'potato'] [20, 15, 10] Here is the code. var itemsToBuy = { milk: { quantity : 5, price: 20 }, ...
user avatar
0 votes
2 answers
62 views

I started learning Swift on my own from books and a tutorial from YouTube. And when I tried to repeat over the video, I got the error "Thread 1: Fatal error: Unexpectedly found nil while ...
Aleksandr 's user avatar
0 votes
1 answer
75 views

my_num_1 = 10 my_num_2 = 20 # I want to assign value 5 to above two variables like this: for num in [my_num_1, my_num_2]: num = 5 That won't work. So is there a way to do something like this ...
dungarian's user avatar
  • 233
0 votes
2 answers
6k views

console.log(answerKey); for(singleKey in answerKey){ } answerKey is my object. Can anybody please tell that how can I access object key names and values. Please see the screenshot (https://prnt....
Satish Thakur's user avatar
0 votes
1 answer
375 views

When a user taps a button, that triggers a lengthy function consisting of an API call and calculations. @IBAction func buttonTapped(_ sender: Any) { var itemIndex = 0 let ...
amirbt17's user avatar
  • 611

1
2 3 4 5
13