0

Now I'm facing other issue. How to make function skaic to take Obects properties, as "min" as "a", "sms" as "b", "inter" as "c", and d,e,f as user input?

var omni1 = {
        min:100,
        sms:300,
        inter:500
        };
    var omni2 = {
        min:300,
        sms:350,
        inter:1000
        };
    var omni3 = {
        min:60,
        sms:100,
        inter:3000
        };
    var bite1 = {
        min: 1000,
        sms: 1000,
        inter: 1000
    };
    var bite2 = {
        min: 1000,
        sms: 50,
        inter: 100
    };
    var bite3 = {
        min: 50,
        sms: 1000,
        inter: 50
    };
    var tele1 = {
        min: 450,
        sms: 250,
        inter: 300
    };
    var tele2 = {
        min: 250,
        sms: 500,
        inter: 650
    };
    var tele3 = {
        min: 4000,
        sms: 3000,
        inter: 4000
    };


    function skaic(a, b, c, d, e, f) {
        return Math.sqrt(((a - d)*(a - d) + (b - e)*(b - e) + (c - f)*(c - f)));                
    };  

Function is to find best solution befitting users needs. Objects are mobile plans of providers, user should input his needs, and application should found, which one is closest to user needs.

Justinas Talandis
  • 101
  • 1
  • 1
  • 7
  • based on the code you have provided you have a quotation mark around one of the object property values. sms:300", needs to be sms:300, – floor Apr 22 '15 at 16:35
  • `int` is a reserved keyword in Javascript. You should not use it as an array key. – ByteHamster Apr 22 '15 at 16:37
  • Are you getting errors in the console, because that should work. You might try using double quotes in your HTML instead of single quotes, but that's all I can think of ``. Is `script.js` in the same path as the HTML? – Andy Apr 22 '15 at 16:38
  • please post the error you are getting in console. – Vijay Apr 22 '15 at 16:40
  • Thanks for notes, It was problem with Int element. – Justinas Talandis Apr 22 '15 at 16:41
  • FYI, [reserved words can be used as object key names](http://stackoverflow.com/a/5371101/1377002), but only in more recent browsers by the looks of things. – Andy Apr 22 '15 at 16:43
  • [`int` isn’t even a reserved keyword](http://mdn.beonex.com/en/JavaScript/Reference/Reserved_Words.html). (Don’t use W3Schools as your source…) – Sebastian Simon Apr 22 '15 at 16:46
  • @Xufox Int is a reserved word. Although not implemented for anything yet. It is still a reserved word. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Future_reserved_keywords – floor Apr 22 '15 at 16:51
  • @floor [Apparently not](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf)… `int` was reserved in older standards (as it says on the MDN page). ES1–3 are way obsolete. – Sebastian Simon Apr 22 '15 at 17:01
  • 1
    @Xufox I stand corrected. But in light of it, it is still technically a reserved word just not in current releases haha. On that note... OP must be lying about int causing the problem. – floor Apr 22 '15 at 17:20

0 Answers0