Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,598 members, 7,955,196 topics. Date: Saturday, 21 September 2024 at 07:19 PM |
Nairaland Forum / Science/Technology / Programming / Dairy Of Javascript Challenge (2017 Views)
Who Has The Complete Version Of Javascript By Tutorials Point? / What are the Advantages Of Javascript Framework Over Vanilla Javascript / 30 Days Of Javascript Challenge {June 21 - July 20} (2) (3) (4)
Re: Dairy Of Javascript Challenge by 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 remember parts of the codes I'll try to write a modifications of the code soonest. |
Re: Dairy Of Javascript Challenge by LikeAking: 12:17pm On Apr 14, 2022 |
Capslock01: I observed that later. Its not flexible. I will modify it. Thanks |
Re: Dairy Of Javascript Challenge by 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)) |
Re: Dairy Of Javascript Challenge by 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.
|
Re: Dairy Of Javascript Challenge by 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] |
Re: Dairy Of Javascript Challenge by 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]); |
Re: Dairy Of Javascript Challenge by 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. |
Re: Dairy Of Javascript Challenge by Altairx440: 7:41pm On Apr 14, 2022 |
It is possible to indent properly in nairaland using "[<code>]content[/<code>]" tags, without the < & > brackets. |
Re: Dairy Of Javascript Challenge by 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 pass most testcases. |
Re: Dairy Of Javascript Challenge by 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
|
Re: Dairy Of Javascript Challenge by 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 |
Re: Dairy Of Javascript Challenge by 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. |
Re: Dairy Of Javascript Challenge by 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? |
Re: Dairy Of Javascript Challenge by LikeAking: 10:06pm On Apr 14, 2022 |
Altairx440: Checking! |
Re: Dairy Of Javascript Challenge by 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. |
Re: Dairy Of Javascript Challenge by Altairx440: 10:43pm On Apr 14, 2022 |
LikeAking:Good job, we'll be waiting. |
Re: Dairy Of Javascript Challenge by Shedrach00(m): 7:57am On Apr 15, 2022 |
Well done Op. This is a very good way to sharpen your coding skills. |
Re: Dairy Of Javascript Challenge by 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 |
Need A Skilled Developer / Why I Am Stepping Into Rust / Get Our New Website Programming And Services At Special Discount This JULY.
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 40 |