HTML5 Game 5 – Part 3: Check Arrays



Finishing up the array prototypes

Source: http://www.farrisarts.com/demo/framework.js

Twitter ► http://brentfarris.com/twitter
Website ► http://brentfarris.com
GitHub ► http://brentfarris.com/github

source

Related posts

Unreal Engine 6: Devasa Metaverse ve Verse Devrimi Geliyor!

PLAYSTATION a besoin de VOUS 🚨 Suikoden plusieurs annonces 😍 Tony Hawk de retour 🛹

Ninja Gaiden 4 – Game Overview | Xbox Developer Direct 2025

2 comments

@diamondglitter205 October 20, 2024 - 11:13 pm
these functions will absolutely come in handy when creating NPCs
@PhreeLyfe October 20, 2024 - 11:13 pm
not sure if i missed something on the Contains function, but it just kept returning a value of false, no matter what arg i passed in, unless the 0'th position was the value I was looking for.. any ideas? I had to modify the code a bit to get it to work .. 

Array.prototype.Contains = function(arg) {
    if (this.length > 0){
        var state = false;
        for (var i = 0; i < this.length; i++) {
            if (this[i] == arg) {
                state = true;
                break;
            }
        }
        console.warn(state);
        return state
    } else {
        console.log("Please Provide A Valid Array With Length > 0");
    }
}

Would this be ok?

Comments are closed.

Add Comment