NewStats: 3,264,641 , 8,184,304 topics. Date: Wednesday, 11 June 2025 at 08:09 PM 6u206z3e3g |
Dairy Of Javascript Challenge (2270 Views)
Capslock01: 9:29am On Apr 14, 2022 |
LikeAking: Haaa! I saw your code in the midnight. It worked for some position of elements in arrays. But not all cases probably because of the arrayOfNumber[0]. I was hoping to come and comment on it when I review proper so that it won't be that I'm too hasty without reviewing proper. Guess you saw it too. But I was able to learn things from it. I can still parts of the codes I'll try to write a modifications of the code soonest. |
LikeAking: 12:17pm On Apr 14, 2022 |
Capslock01: I observed that later. Its not flexible. I will modify it. Thanks |
LikeAking: 3:18pm On Apr 14, 2022 |
Capslock01: ---See this 1--- Test on diff arrays, then get back to me, thank you. function takeTwoInputs (arrayOfNumbers, targetNumber) { for(const value of arrayOfNumbers){ let num = targetNumber - value; if(arrayOfNumbers.indexOf(num) !== -1 && num + value === targetNumber){ return [arrayOfNumbers.indexOf(value),arrayOfNumbers.indexOf(num)] } else{ return [-1,-1]; } } } console.log(takeTwoInputs([9,4,5,6,3,1,0], 10)) console.log(takeTwoInputs([2,45,9,6,1,53,9],47)) console.log(takeTwoInputs([4,9,3,5,0,14,10],100)) |
Capslock01: 7:28pm On Apr 14, 2022 |
LikeAking: Great one boss! It worked but not in all cases again when I switched the position of the 9 and 1 or maybe it's a fault from my end. Thank you for taking out time to review. I'm really learning from your code.
|
Capslock01: 7:30pm On Apr 14, 2022 |
Don't know if there's any one following. I'm sorry for keeping you hanging, I was caught up with work. Here's today's challenge. Day 7 Create function that takes an array of unsorted numbers and sort them. NB: You can't use the built-in sort function. For example [1,9,4,5,3,0] => your function [0,1,3,4,5,9] [2,5,9,6,1,53,45] => your function [1,2,5,6,9,45,53] [4,9,-3,5,0,-14,10] => your function [-14,-3,0,4,5,9,10] |
Capslock01: 7:32pm On Apr 14, 2022 |
Capslock01: // Day 7 //Rearrange an unorganized Array function arrangeArray (thatArrayToArrange) { for (let i = 1; i < thatArrayToArrange.length; i++) { for (let j = 0; j < i; j++) { if (thatArrayToArrange[i] < thatArrayToArrange[j]) { let temp = thatArrayToArrange[i]; thatArrayToArrange[i] = thatArrayToArrange[j]; thatArrayToArrange[j] = temp; } } } console.log(thatArrayToArrange); } arrangeArray([1,9,4,5,3,0]); |
Altairx440: 7:38pm On Apr 14, 2022 |
Capslock01:I'm following, I just don't post my codes, I guess I'll have to start posting my codes. |
Altairx440: 7:41pm On Apr 14, 2022 |
It is possible to indent properly in nairaland using "[<code>]content[/<code>]" tags, without the < & > brackets.
|
Altairx440: 7:47pm On Apr 14, 2022 |
LikeAking:You can try using two loops to check for every possible pair, that should be easier, your code does not most testcases. |
Altairx440: 8:10pm On Apr 14, 2022 |
Capslock01:day 7 I'm so used to writing python that javascript is now a pain, anyways, here's mine
|
Capslock01: 9:16pm On Apr 14, 2022 |
Altairx440: Thanks for following boss. I do appreciate. Please be posting. It'll go a long way in helping to understand how things can be done better. 1 Like |
Capslock01: 9:18pm On Apr 14, 2022 |
Altairx440: Wow! Thanks boss. Never knew this. I'd be using it in going forward. Thank once again boss. Altairx440: Yeah. True. Thank you for the two loops pointer. |
Capslock01: 9:43pm On Apr 14, 2022 |
Altairx440: Great! Thanks for sharing boss. It shows in your code that you're a Python writer. Some variables names (min_index...) are following Python way of naming. You know JavaScript mostly use CamelCase. Care to share what you use Python for? Backend? |
LikeAking: 10:06pm On Apr 14, 2022 |
Altairx440: Checking! |
Altairx440: 10:40pm On Apr 14, 2022 |
Capslock01: Well not really, I just like python, its simplicity and elegance resonates with me but yeah I've built a project with python and flask, an auto corrected typing speed app though not from scratch. I'm not even old enough to talk about jobs yet, but I like the idea of working remotely and node js seems to be standard so I also plan on learning it when the time comes, sorry I'm off topic. I'll fix my code and please don't call me boss, you're the real boss. |
Altairx440: 10:43pm On Apr 14, 2022 |
LikeAking:Good job, we'll be waiting. |
Shedrach00(m): 7:57am On Apr 15, 2022 |
Well done Op. This is a very good way to sharpen your coding skills. |
3exe3: 9:07am On Apr 15, 2022 |
qtguru: Really?? Learning web flow and figma currently. Before I will apply let me finish with the project I got on hand. So I can present something |
Help On Loading Sql Table Data Into Datagrid Using OOP Approach C#
(Go Up)
Sections: How To . 35 Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or s on Nairaland. |