konijn
  • Member for 9 years, 6 months
  • Last seen this week
  • Lyon, France
Milliseconds to Time string & Time string to Milliseconds
8 votes

To start, I would like to offer an analogy; you have built a really fast car with a hood that wont open ( it's hard to maintain ), and you keep insisting that it's okay, because the car is fast. We ...

View answer
Write a function to find the first non-repeated character in a string
Accepted answer
8 votes

After playing a lot with jsperf and having to admit that the regex solution is actually faster, which annoys me. Your first approach is far superior than your second approach (O(2n) -> O(n^2)) as per ...

View answer
Assigning width and height to specify image dimension using jQuery
Accepted answer
8 votes

The reason GTMetrix complains is that the browser can render the page faster if it knows the size of the image. Setting the size after the browser has rendered is not going to make your page faster, ...

View answer
Linking to an image asset from a JavaScript file in Symfony 2
Accepted answer
8 votes

There might be a better way to retrieve the web directory, I would not know. However, there are other things to ponder upon. Naming : loadBkrndImg -> loadBackgroundImage looks so much better Naming : ...

View answer
Templating libraries' intelligibility and their performance (compared to mine)
8 votes

From a once over: delimiter should be delimiters var string = new String(); could be var string = '';, it raises less questions On a general note, I think it is bad design to AJAX each template.. ...

View answer
JavaScript text-based RPG
8 votes

General One of the best ways to learn a language is to write an RPG in it, because you can write working code with just basic knowledge, and then you keep polishing for a really long time. Since ...

View answer
Count byte length of string
8 votes

My 2 cents Please do not abbreviate words, choose short words or acronyms ( Len -> Length ) Please lower camel case ( normal_val -> normalValue ) Consider using spartan conventions ( s -> generic ...

View answer
Replace ' ' Spaces in a URL with a '%20' - Coding Challenge
7 votes

From a short review: If you are going to write your own replace, then you should create a method for it, so that you can call myReplace( string, target, replacement); Personally I would have checked ...

View answer
Increment a text field value
7 votes

Not a question that fits CR well. This is clearly short, untested sample code. You need $("#counter"), not $(".counter"). var counter = $("#counter") counter.html( parseInt(counter.html()) + 1 ) ...

View answer
Naming numbers in American English
7 votes

Interesting question, impressive code. I only found one thing that could be considered a bug: nameNumber('15.000') will return "one hundred fiftyundefined thousand", this could be fixed by changing ...

View answer
NodeJS broker between MongoDB and RabbitMQ
Accepted answer
7 votes

Interesting question, it was hard to find things I would do different. To Malachi's point, there are a few strings you could put in a config object, I would definitely add also 10000 to that config ...

View answer
Reusable Ajax object
Accepted answer
7 votes

From a quick once over: JsHint.com has very little feedback, good! Consider using use strict to activate strict mode Avoid console.log Both beforeSend , error and complete should be customizable by ...

View answer
Basic JavaScript OOP model object
Accepted answer
7 votes

For your questions: The usage of this : In my mind, unless you are using closures, do not use self = this, so only keep it in getMissions Functions in prototype <- Good stuff Function <> JSON, ...

View answer
Caesar cipher implementation
7 votes

Your code is reviewable, even if it does not work, from a once over: Indent your code (!!), this is bad: function Caesar(order){ this.order = order; this.encode = encode; function encode(input){ ...

View answer
Unordered list element via templating
Accepted answer
7 votes

Interesting questions. Is setting 'style' still considered bad practice when creating elements through templating? Only if you cannot reasonably use css classes (which is your case) Should I be ...

View answer
MS Excel type of grid in jQuery
7 votes

From a once over: The column and row count should be a parameter/variable/default The namespace JS.training seems like overkill, I doubt anybody would ever use 2 libraries for showing datagrids ;) ...

View answer
First jQuery Plugin - SmoothSlider
Accepted answer
7 votes

Overal, I think this is very good code, I only have a few pointers. Unused variables ( jshint ). scrollOffset continuousScrollSpeed autoScroll autoScrollSpeed autoScrollDirectionChangeDelay Yoda ...

View answer
Responsive jQuery plug-in
Accepted answer
7 votes

My 2 cents : Why jQuery, libraries targetting mobile should not require jQuery, #perfmatters Your github project should have a production version where debug is excluded, your code is 4215 bytes ...

View answer
Setting currency and language values
7 votes

My 2 cents: Use jQuery toggleClass : http://api.jquery.com/toggleClass/ Use camelCase : currencycode -> currencyCode etc. Use English everywhere : 'monnaie' should not be there Booleans are awesome ...

View answer
Javascript function to return an array that needs to be in a specific order, depending on the order of a different array
Accepted answer
6 votes

I would Encapsulate the names and colors in a data structure Use .map instead of .forEach So something like this; function chartBackgroundColor(collection){ const nameColorMap = { "...

View answer
Converting duplicate JS code into a higher order function
Accepted answer
6 votes

From a short review; Why hardcode the batch length to 500 ? Why not have the batch length be a nice constant ? You have even hard coded the length in the function name, which is really unfortunate ...

View answer
Vowels and Consonants
Accepted answer
6 votes

From a short review; arr1 and arr2 are terrible names, we could call them consonants and vowels accessing sp[i] so often is not efficient, I would store that value in a variable when dealing with ...

View answer
Alternative code to classes in Javascript?
6 votes

A short review; In stacktraces, person will be a nameless function, use function person(){} instead There is no good reason to have different names (first->firstName) for your attributes. Using the ...

View answer
Beginner's JavaScript calculator
Accepted answer
6 votes

Interesting question, I noticed that 9-3*3 does not return 0, but 27, you are not following PEMDAS Personally, I would make sure that the input only contains numbers, dots, and math operators, and ...

View answer
Test if a string is a palindrome
Accepted answer
6 votes

Good question, as Joseph mentions, white listing is usually a better approach, and in this case it is also the more readable approach. I like your approach better, it avoids re-writing the wheel When ...

View answer
Checking that an entered date is before the current date
6 votes

Just wanted to chime in: Nobody mentioned this, but isValidDate() to determine whether 1 date is earlier than another date is frankly terrible. Call it isEarlierDate() Where are the variables? Are ...

View answer
Get <TH> texts into a tab separated string
Accepted answer
6 votes

CoffeeScript is not my forte, however I quite like this approach: elements = $(this.dom.table).find("thead tr th") table_with_headers2 = ($(element).text() for element in elements ).join('\t') This ...

View answer
Cordova file management
6 votes

Interesting question, it is of course not good to fill up memory with copies of pictures. Especially with this scandal in recent memory where deleted pictures haunt users. It seems from reading your ...

View answer
A hotel greeter named Alfred
Accepted answer
6 votes

From the comments, I guess you would like a theoretical review ;) This: <button onclick="javascript:alfred('greet')">Arrive at Hotel</button> <button onclick="javascript:alfred('...

View answer
Correct way to extend Bootstrap Modal - lock, unlock
6 votes

Flambino did an excellent review, the only nitpick I have is that I would write $.fn.modal.Constructor.prototype.hide = function (_relatedTarget) { if (this.isLocked) return; return oldHide....

View answer
1
2
3 4 5
27