Make Array Consecutive 2 | CodeFights Intro Algorithm JavaScript Solution and Breakdown
Support our Community:
-Donate:
-Patreon:
-Code, Tech and Caffeine Facebook Group:
-Discord:
– Looking for a a Bootcamp check out DevMountain’s program where housing is included with the tuition:

Tutoring, Mentoring and Course Walkthroughs available:

Thank you to my Patreon Supporters Below:
-Check out youtube.com/user/cardinalslinkyband

Support me and visit my store at:

Internship, Part-Time, & Full time work for college students and recent grads:

Fan funding goes towards buying the equipment necessary to deliver 4k videos, 4k webcam, and a high quality microphone better audio. Any support is very appreciated!

My channel is here for aspiring programmers to learn easier and help debug any issues from the many great free resources available on the web.

Check out my other videos going over HTML, CSS, Ruby, Ruby on Rails, Java, JavaScript, Python, PHP, SQL, Command Line, BootStrap, jQuery, and WordPress from CodeCademy, CodeCombat, FreeCodecamp and more!

-~-~~-~~~-~~-~-
Please watch: “How I Became a Developer | My Developer Journey of the Last 3 Years | Ask a Dev”

-~-~~-~~~-~~-~-

Nguồn: https://tintucgame.net

Xem thêm bài viết khác: https://tintucgame.net/giai-tri/

10 COMMENTS

  1. can you solve without a for loop? I try to avoid use for loops in my code though haven't been successful with forEach()

  2. what is the point of doing `statues.sort((a,b)=> {
    return a – b;
    });`? if .sort() automatically puts it in numeric order?

  3. there is no need to sort the array like this, or index it, at all. anyone who does so has no idea what they're doing, especially if they don't >sort(compare)< them with >>statues.sort(function(a, b){return a > b})<< instead of the (a,b=>[a+-b]) bullshit all these bozos do. or at least explain to people why an empty sort wouldn't work if any of the numbers were over "9". why make tutorials if you don't know what you're doing? this isn't educational, it's a waste of time and should be in the entertainment or comedy section. I've watched several of your videos and not a single one would be helpful to anyone, at all. At most, other people who don't know what they're doing wither can get the answer here, but for those who really are looking for help understanding, this makes less than no sense and will confuse them more because nothing is explained and the things done don't even make sense. It's pretty clear this guy just got these answers somewhere else, because no sane person who knows what they're doing would do them these ways shown in his videos. Same goes for a few of the other shitbags making these videos. I did not fought in Iraq for 4 years just so I could come home to this. I'm a Navy Seal and I have several medals. Do you know what I'd do to you? Stop making these videos or else. I’ll have you know I graduated top of my class, and I’ve been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I’m the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with making terrible tutorials over the Internet? Think again, fucker.

  4. This doesn't work for their hidden tests. You'll succeed upon hitting "run tests", but will get a 9/10 and fail once you try to submit

  5. I think this works (I am not sure because I didnt read all the problem):

    let arr = [6,2,3,8];

    function missingNums(arr) {
    let newArr = [];
    for (let i = Math.min(…arr); i <= Math.max(…arr); i++) {
    newArr.push(i);
    }
    return newArr.filter(n => !arr.includes(n));
    }

    console.log(missingNums(arr));

  6. My solution was quite different. instead of having a min and max, I looped through the array with var i = 1 and compared statues[i] – statues[i-1] to 1. If the number of statues[i] – statues[i-1] was !== to 1, I would take that number, subtract it by one, and add it to the count variable.

    function makeArrayConsecutive2(statues) {
    statues.sort(function(a,b) {return a – b});
    var count = 0;
    for (var i = 1; i < statues.length; i++) {
    if (statues[i] – statues[i-1] !== 1) {
    missing += statues[i] – statues[i-1] – 1;
    }
    }
    return count;
    }

  7. you can just do this : return (Math.max(…statues )- Math.min(…statues))-(statues.length-1);
    basically i dont sort it and just get the max and min

LEAVE A REPLY

Please enter your comment!
Please enter your name here