Ad
  • Default User Avatar

    It's works!

    I have

    Array.prototype.sum = function() {
     for (var i = 0, sum = 0; i < this.length; sum += parseInt(this[i++]));
     return sum;
    };
    

    Function "sum" is guilty. Why? I do not know.

  • Custom User Avatar

    Thanks! Good job!

  • Custom User Avatar

    Do you have a n in your solution? Could you post your solution? (mark it as spoiler).

    Edit: thanks for your feedback! No need then to post your solution...

  • Custom User Avatar

    the problem was 'use strict'; on top of my code

  • Custom User Avatar

    lang JS, passes all basic tests and fails with error:

    Random tests
    ReferenceError: n is not defined
       at do_ex
            at Object.Test.describe
    
  • Custom User Avatar

    First of all: this time your post is perfect!
    Nevertheless I'm worried - for you and for me - : you are getting the "good" result but for a reason I don't know it seems that CW don't give the good "expected".
    I verified once more the tests.
    They are of the good form:
    Test.assertEquals(actual, expected, msg) with here

    Test.assertEquals(orderWeight(a), orderWeightSol(a) ,"It should work for random tests too")
    

    where a is the input string. Maybe you could post your solution (mark it as spoiler), I will try it to see where the problem is.
    Sorry for that inconvenience that doesn't seem to come from the kata since I tried my solution and a few others some time ago and just now again with no problem as I told you. Do you modify the input string to get your result? Anyway whatever I see it's now impossible to modify something in this kata since there are more than 500 people who passed it.

  • Default User Avatar
    Testing Order Weights: 471333 127 189301 184 195296 185 305839 199 409179 101 288517 87 113430 182 265352 166 292037 129 454429 92 32
    

    My function input (console.log()):

    471333 127 189301 184 195296 185 305839 199 409179 101 288517 87 113430 182 265352 166 292037 129 454429 92 32
    

    My function output (console.log()):

    101 32 127 182 92 113430 129 166 184 185 87 199 471333 189301 265352 292037 305839 454429 409179 288517 195296
    

    Console output:

    It should work for random tests too - Expected: 471333 32 189301 184 195296 185 305839 199 409179 101 127 87 113430 182 265352 166 292037 129 454429 92 288517, instead got: 101 32 127 182 92 113430 129 166 184 185 87 199 471333 189301 265352 292037 305839 454429 409179 288517 195296
    
  • Custom User Avatar

    You are kind but your post is unreadable. I said between backticks (google "markdown backticks" to see how to proceed if you don't know). Furthermore I need only the result of one random tests, not all... Plus: you can console.log your input and output to compare with expected and actual.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Seems that you are swapping "Expected" and "got". Please put exactly what it is shown between three backticks ....
    I tried once more my solution and a few solutions from CW who passed the kata and had no problems at all...

  • Default User Avatar

    In Javascript again:

    Testing Order Weights: 3586 17 135122 66 105243 168 142653 64 407988 34 388602 127 108585 99 100626 12 291904 180 340923 176 2

    It should work for random tests too - Expected: 3586 2 135122 66 105243 168 142653 64 407988 34 17 127 108585 99 100626 12 291904 180 340923 176 388602, instead got: 2 12 34 17 180 127 64 66 135122 176 100626 105243 168 99 142653 340923 3586 291904 108585 388602 407988

    And others "Random tests".