Find your pokemon - how does it work? JS [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
So I found this site http://pokemon.step.lv/
If you type in your name and surname, it gives you your pokemon. I was just wondering, if somebody tells me which pokemon they are, is it possible for me to figure out their name?
I don't want to use it in any bad way, I'm just really curious, I tried to find something in this code http://www.google-analytics.com/urchin.js but I'm just a beginner at programming in general so it's pretty difficult for me, but it also makes me more interested in it.
If anyone is bored enough to try to help me, please just take a look

I'm not sure how many pokemon there are. But I know there are fewer pokemon (men)? than there are names.
There's something called the pigeonhole principle that states, essentially, if you have n pigeons, and n-1 pigeonholes, each pigeon can't have its own hole. It's the same thing with names. Since there are more names than there are pokemon, there must be people who share the same pokemon. Thus, the answer is no, it's impossible.

There is an array of pokemons. Server side script calculates hash-code from your name and gets an element from this array according to this hashcode. An arbitrary logic can be applied here, to generate array index from this hashcode.

Related

Trying to understand the jQuery('#none') selector [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I am working on a small project for work and I came across a piece of code that is iterating a counter, and if that counter is not 0 then it executes this small bit of code:
if (cnt) jQuery('#none').prop('checked', false);
I am trying to understand what the jQuery('#none') selector is. When I execute it alone as just a selector within the chrome console, it returns an empty set. I have been googling for about 30 minutes, searching jQuery/JavaScript/CSS docs and all I can find are a few references to things where people are using this selector, but the topic in question is not in regard to the selector itself. To me this line appears to be doing literally nothing as commenting it out does not seem to change the behavior.
I really prefer to not mess around with stuff I don't understand as that almost always results in bugs. Can anyone point me to some documentation or just explain here what the #none selector is?
EDIT:
It would appear there is no magic #none selector. My assumption is this was left over from a previous iteration, it threw me off since the person who originally wrote it does not write erroneous code like this and I was finding people using the same selector online with no explanation - but those instances were red herrings.
jQuery('#none') selects all elements where id=none. If there are no elements with the id of "none", then it will return an empty set.
<div id=none>This div has the id = "none"</div>
It sounds like you found a piece of 'cruft' (aka zombie code).

What is a List ? [JavaScript interview question] [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
What exactly is a "List" in JavaScript?
I got asked this question and I'm a professional of five years but this made me fumble.
I understand Arrays, Stacks, Queues, even Linked Lists.
But isn't a List just an Array in JavaScript? Because then I got asked what the difference between a List and an Array was, and I said no difference - and never got to know if that was right.
I understand the differences between the data structures List and Array in C# and Python but I don't get this one for JavaScript.
I understand the downvotes ... it was indeed a dumb question, I think I should have known that Lists weren't a type in JavaScript and tackle the dumb question that way.
For anyone this may prove useful: For front-end engineer interviews, make sure you know that JavaScript is a dynamic language, meaning the data structures are very different from static typed languages like C and Java, and even have different meanings in Python even though Python is a dynamically typed language similar to JavaScript.

How can I implement an incremental suggestion for html textbox via JavaScript? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Here's what I would like to do...
Lets say I have a list of tags (ex; Animals, Alphabet, Buildings, Food). I want to make it so that, as the user starts typing "A", they are then shown Alphabet (with the "lphabet" part highlighted and the cursor residing just after the "A"). As the user types, they are free to hit tab and accept the suggestion or they can continue typing in a custom value.
Is this possible?
What's the best way to implement this?
Currently, I am just replacing the value in the textbox with the matching value from the list (if found). This doesn't work very well as it is difficult to use a custom value if it is close to an existing item in the list as the value is constantly overriden by the suggestion.
Thanks!
There is a JQuery plugin for Autocomplete.
http://jqueryui.com/autocomplete/
It seems as if you are describing an autosuggest feature. You may find a lot of answers by searching the term.
If you have a known set of answers that is relatively short you may take advantage of the datalist as seen here http://www.w3schools.com/tags/tag_datalist.asp
If you have a very large or list that could depend on a database query you may be getting into a more complicated version. In this case I would look into JSON / AJAX Autosuggest.
Don't reinvent the web :)
After stepping back to see the forest for the trees, I realized I could get essentially what I was looking for with the following...
<input list="tags" name="tag">
<datalist id="tags">
<option value="Animal"></option>
<option value="Alphabet"></option>
<option value="Buildings"></option>
<option value="Food"></option>
</datalist>

Testing for string in file using javascript [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a 5K text file of vocabulary words (over 100,000 words, either in xls or txt file). I only want to test if a given string exists in the text file using javascript / jquery.
1) Do I need a library function to do this?
2) Is the size of the file a problem in terms of performance?
Thanks for any help...
Since you haven't tried anything yet or provided code, I'll give you a general layout and place to start.
1) Get your data file via Ajax
2) Use indexOf or match to check for a match. Performance stats here.

Replace Js Variables names using PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I search about protect my javascript code by changing his variable names (complicate the code lisibility like on jQuery).
i find jasob application and i like it because it change maximum variables compared with other system like jscompress
i want to create php code that can transform maximum of varibles and put the compared in database to reverse action, it's seems to be very difficult to do.
Can someone know a existant code like this have proposition to simplify?
protect my javascript code
I don't think that is practically possible. JavaScript is rendered on Client-Side, so no matter you do security, the JS files still going to be downloaded on the client-machine.

Categories