293 karma · joined July 21, 2015
This seems... factually incorrect? Shouldn't it say "a double"? (or a "number", which just means "double" in JS)
It might ignore any characters after a ".", but it's impossible to return an integer in JS...
The second case is easily handled by static languages, for example, in Swift:
var mydata = ["foo": Dictionary<String, MyObject>()]
mydata["foo"]["bar"] = MyObject()
This is only longer than it needs to be because of using two lines, you wouldn't need the explicit declaration to do it in one: let mydata = ["foo": ["bar": MyObject()]]
This also gets rid of mutable state!Note that this is fixed by just averaging your actual grades out of 100 to form your GPA, instead of mapping from a 0-100 range to an enumeration to a 0-4 scale then averaging the results.
Note that, of course, this would be fixed by just making GPAs decimal numbers out of 100, the average of all of your actual, numeric grades from each course (multiplied by credit hours?). You can divide it by 25 if you really want the weird 4.0 scale for some reason.