javascriptember.jsfirebaseember-cliember-cli-addons

Ember cli Uncaught TypeError: undefined is not a function


I am an ember noob and i originally built my app without ember-cli it works fine then i got the bright idea of rebuilding my very simple app with ember-cli what could possible go wrong:)

Everything works the same in both apps until ember throws an error and points me to line 52 in my verse controller keep in mind that this file is exactly the same in my non ember-cli version

Update i just put a lot of spaces where line 52 was and now it is saying the error is on line 53 which is empty:(((

import Ember from 'ember';

export default Ember.Controller.extend({
    sortProperties:["time"],
    sortAscending:true,
    start:new Date(),
    count:0,
    incorrect:0,
    startReview:true,
    showHighScores:false,

    actions:{

        startReview:function(){
            this.set('startReview',false);
            this.set("showHighScores",false);
            this.start = new Date();
            this.count = 0;
            this.incorrect = 0;
            console.log(this.count);
        },

        showHighScores:function(){
            this.toggleProperty("showHighScores");
        },

        checkCorrectness:function(word){
            var textArray = this.get("model.text").split(" ");
            var length = textArray.length;
            console.log(this.array);
            if(word === textArray[this.count]){

                console.log("correct");
                this.count++;
                console.log(this.count);
            }else{
                console.log("Incorrect");
                this.incorrect++;
            }
            if(length === this.count){
                var finish = new Date();
                var time = finish-this.start;
                var accuracy = (this.count/(this.count+this.incorrect)*100);
                alert("You took "+time/1000+" seconds! With "+accuracy+"% accuracy!");
                this.saveResult(time);
                this.set('startReview',true);
            }
        },
    },
    randomizer:function(){
        this.set("randomArray",this.get("model.text").split(" ").randomize());      
    **}.observes("startReview"),**//The offending line

    saveResult:function(timeTaken){
        var date = new Date(),
            userName = "TimTheGreat";


        var score = this.store.createRecord('score',{
            userName:userName,
            date:date,
            time:timeTaken,
            verse:this.get('model'),
        });

        var controller = this;
        var scores = controller.get("model.scores");
        score.save().then(function(score){
            scores.addObject(score).then(function(){
                controller.get("model").save();
            });

        });
    }
});


Solution

  • The offending line is actually the line before.

    this.set("randomArray",this.get("model.text").split(" ").randomize());
    

    Neither in Ember nor in native javascript do arrays have a randomize method. This is something either you or another lib you were using added before.