Programming Fundamentals Mid Exam Retake проблем
Здравейте, имам проблем със задачата 03. Memory Game.Judge ми дава 85/100 и не мога да намеря грешката в кода ,ако може някой да удари едно рамо ще съм благодарен.
https://pastebin.com/vRKKe7aa
Здравейте, имам проблем със задачата 03. Memory Game.Judge ми дава 85/100 и не мога да намеря грешката в кода ,ако може някой да удари едно рамо ще съм благодарен.
https://pastebin.com/vRKKe7aa
Грешката е, че проверявате дали стойностите в масива, сочени от двата индекса са еднакви, преди да сте проверили дали индексите не са еднакви.
Разменете последователността им и задaчата ще мине с 100/100:
if (typeof sequence[indexOne] === "undefined" || //...
// ...
else if (sequence[indexOne] === sequence[indexTwo])
// ...
...
Благодаря!
You handled that job well!
cookie clicker
Здравейте Мартин,
Имам подобен проблем, 85/100 бия си главата от доста време с тази задача. Би ли погледнал.
Благодаря предварително!
https://pastebin.com/yFq0Ukd8
Haven't tested it, but I've got a feeling that your splicing operation inside of your forEach does not consider the mutated array after the first element has been removed from the array. After eliminating the first element establish the index of the second element on the mutated array.
Plus in your checkValidIndex, should it not be =>
Demo code
Hey, Thanks for your suggestions. However I have implemented what you suggested and changed the forEach() with the option you provided and i still get 85/100. Not sure if it helps but its the middle test showing wrong answer.
Here is the updated code:
https://pastebin.com/XQ2D1XF1
Thanks again for having a look into my case!
Refactored the code and now it gives 100%, the forEach was not the issue as it mutated the array from the end towards the beginning - nice idea by the way! It was your matchingElements function, you pass on the actual elements in your array as indeces and turn around the whole logic - surprising that it passes with 85%.
Thanks a lot @Axiomatik. It actually make sence just to check if the two indices are equal, i've complicated it a bit and I am not surpriced it was wrong. Thanks for your time on this! Have a good day ahead.