All Questions
279 questions
1
vote
5
answers
99
views
javascript function looping array
Why can't I get the output I want, I tried various ways but it doesn't work, where is it wrong?
Give me a clue so I can learn.
let laptop = ["asus", "lenovo", "acer", &...
-1
votes
1
answer
51
views
I am new to recursion, I could not get how this program print the output?
I am assuming that this program should give the output [5,4,3,2,1] but it is giving [1,2,3,4,5]. Why this is happening? How the recursion is working here? Please explain me?
function countup(n) {
...
0
votes
1
answer
139
views
How can I reset this tic-tac-toe gameboard for a new round?
I have created a multiplayer tic-tac-toe game where a player selects either 'Player One' or 'Player Two' to begin the game. On selecting either 'Player One' or 'Player Two', a placeMark() function is ...
0
votes
1
answer
65
views
How can I make this loop/function run correctly?
I am making a rock paper scissor game that uses prompts to play.
Here's the entire code
var options = ['R','P','S','r','p','s']
var userRes;
var checkVar;
var compChoice;
var checkStat;
var winStat = ...
2
votes
1
answer
37
views
I'm trying to remove duplicate data from a new array, but am returning array of individual characters instead. What can I do differently?
I have an array of objects saved to:
const arrayOfCustomerObjects
I need to return an array of States based on an array of objects that lists data including address information. In addition, each ...
0
votes
1
answer
238
views
How to iterate through a json dict of arrays using loop postgresql
I am trying to iterate through a json dict of arrays in postgres using a function.
input json:
'{"Key1": ["value1", "value2", "value3"],"key2":["...
1
vote
1
answer
98
views
Extract a complete branch from a Parent-Child data structure in PHP using recursion
I have an object from a sql-query. Every entry has the keys (id, type, title, parent_id).
My example data:
Content of the sql-object $list (var_export()):
$array = array(0 => (object) array( 'id' =&...
1
vote
0
answers
27
views
Plotting a function with a loop
I have this following code where i am basically calculating the MTTDL (Mean Time To Data Loss) of a hard drive. The print(sum(y)) gives me the MTTDL in hours.
import matplotlib.pyplot as plt
import ...
1
vote
1
answer
92
views
Printing out a diceplot histogram
When I complie and run my code I get the same output everytime despite having a random function. It defaults to the trial output shown on the assignment guide. I've tried to alter what's inside the ...
1
vote
1
answer
56
views
How to Add Function Returns as Key-Values in Every Object in an Array
I have multiple functions that calculate values in an array of objects. I am trying to run the functions through all 7,200 objects in my array, and in turn add the return of those functions as a new ...
-1
votes
1
answer
50
views
What do I put for the target 't' variable in the search_array function call? [closed]
This program is a secret 5-digit code guessing game. Each digit of the code is between 0 and 9, and digits cannot repeat in the code. After entering a digit one at a time, the player receives feedback ...
1
vote
1
answer
185
views
Decimal to Hex in C++
I've coded this program to get a number and a base as two inputs, then prints the number in the given base, it does work well when the base is less than 10, but when I enter a base like 16, instead of ...
-2
votes
2
answers
120
views
Identifying the identical elements in two arrays with same location(index)
Ok, so I want to return the elements that are present in both provided arrays having the same index location.
exe1 = [A,B,C,D,N]
exe2 = [B,D,C,A,T]
it should return only C
I've tried looping them by ...
-2
votes
2
answers
52
views
While and array - Using a loop with array
Can someome explain to me how New Array, and Array works with this loop? Also, anyone knows if is possible of doing a array and inside this array a function? Because this way of doing seem kinda wrong ...
0
votes
2
answers
44
views
Why I can't loop this function?
My teacher gave us a lesson where we had to find out how many times a x number was drawn in the lottery. He gave us a .txt document containing all datas from the previous years. He told us to build a ...