Jump to content

Search the Community

Showing results for tags 'issue'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 8 results

  1. What's the issue? The example I am referring to is the Fisher Yates implementation on this page: https://www.w3schools.com/js/js_array_sort.asp This is the code in question: var points = [40, 100, 1, 5, 25, 10]; for (i = points.length -1; i > 0; i--) { j = Math.floor(Math.random() * i) k = points[i] points[i] = points[j] points[j] = k } If you run the example you will see the elements of the array shuffle around and everything will seem to be working as expected. The issue is subtle. With the above code block the element in the last position of the array can never remain in the last position of the array, and, with each iteration, the last element that is referenced can never remain in that position. Why can't the last element contain the same value after shuffle? It has to do with this statement: j = Math.floor(Math.random() * i) Because Math.random() generates a number between 0 and 1 which is inclusive of 0 but not inclusive of 1, the integer represented by i will never be assigned to j. With the above algorithm, i starts by referencing the last index of the array and therefore j can never be the last index. Why does this matter? This algorithm is supposed to produce an unbiased permutation of the elements meaning that every permutation is equally likely. With this shuffle, any element should have an equal chance of being shuffled into any position in the array including the position it already occupies. "Yeah, but, why would this matter in REAL LIFE?" In a practical example, I've needed to solicit feedback from users in a product. This was done by presenting a question with multiple possible answers. In order to prevent bias in the responses, the order the answers were presented was randomized for each person responding. From a code standpoint, each answer would have always started from the same position in the array. With this implementation, the last answer in the array would have never been the last answer presented to the user. This would have unknowingly introduced a different element of bias and skewed the results. Updated Implementations One possible update which still uses a for loop is to use the length of the array as the starting value of i and to decrement only after j has been randomly selected: var points = [40, 100, 1, 5, 25, 10], i, j, k; for (i = points.length; i > 0;) { j = Math.floor(Math.random() * i--) k = points[i] points[i] = points[j] points[j] = k } This looks a little wonky because even though the third statement in a for loop is optional, this is not a typical implementation. If we're going to decrement i inside of the code block, people typically use a while statement: var points = [40, 100, 1, 5, 25, 10]; var i = points.length, j, k; while (i > 0) { j = Math.floor(Math.random() * i--) k = points[i] points[i] = points[j] points[j] = k } I've also declared j and k before use. Generally it is considered good practice to declare variables before using them and using undeclared variables is not allowed in "strict mode".
  2. This page describes pythons dictionary.keys() Method as follows: This, however, is only correct in python 2.x, in python 3.x the keys() method returns a dict_keys Object. Please note that i have never submitted an issue to w3schools before, i dont know if this is the right place to do it or if they intended their Documentation for python 2.x only.
  3. M0013

    Certs

    I dont know if anyone who manages your sites certs knows, but your certs expired 8:00 AM EST
  4. Hello everyone, i must do a query that finds all words that finish whit a,e,i,o or u. i' ve used this query but my output in empty . select City from Station where City like '%[aeiou]'; i' ve used the wildcards wrongly?
  5. I am having what I assume is a CSS issue, because there is a grey background where there should be none. I have attached the code and was hoping someone was able to assist with this issue. Screenshot of the issue: It should look like this: holman-bmw-ft-lauderdale-accordion-x7-page_v3 no carousel.html
  6. Update: I have been informed that there was a "Both font-family and font can be used" answer. I am WRONG!!!! Thanks everyone Just completed the "W3Schools CSS Quiz" that I planned on having our intro interns take when I was suprised by my 95% result. Upon inspecting my incorrect answer I found myself very confused as there clearly was an error. For question 15. Which property is used to change the font of an element? I answer font-family, but was given an incorrect. I have attached screenshots of the question and a google results page of the question and answer in hand. I EXPECT THIS TO BE FIXED SO I CAN RECLAIM MY THRONE AS KING OF CSS, but on on a less sarcastic note, love the site, keep it up, fix the quiz, live long and prosper! cheers, philhoyt
  7. Hi! It's my first post on the forum, and I have a question: My Website works fine on the desktop version, but when I use it on a Smartphone I have problems with Session Expired. Do someone knows if I have to threat mobile and desktop session by a different way?
  8. Hello! I'm new here and I am dealing with a little problem which I hope you guys can help me with! What I want to achieve: Basically what I want to happen is that when the logo gets hovered the black message box will fade in using css transitions. Take a look at the image below and you will get me. And when the mouse moves away from the logo the message box fades out to zero again. But something is wrong, I dont know what. https://docs.google.com/file/d/0B0ONzhkyFUwhQXNOTFJzb0lVSFE/edit?pli=1 <-- image to make you understand. What I am dealing with: Thanks for staying with me, here is my HTML, CSS AND jQuery HTML: <div id="colume"> <div id="logo-to-hover"><a href="#"><img src="images/villave-logo.png" alt="villave-logo" width="220" height="53" /></a> </div> <!-- end logo-to-hover--> </div> <!-- end colume--> <div id="message"> <div id="box-1" class><p>Byggvareforhandler</p> </div> <!-- end box1 --> </div><!-- end message--> jQuery: <script>$(function() { $( "#logo-to-hover" ).hover(function() { $( "#box-1" ).toggleClass( "box-a"); return false; });}); </script> CSS: #logo-to-hover { width: 220px; height: 55px; margin-right: 20px; float: left; } #boxes { width: 940px; height: 71px; margin-left: auto; margin-right: auto; position: absolute; } #box-1 { height: 44px; width: 200px; margin-left: 10px; margin-right: 10px; background-image: url(../images/hoverbg.png); float: left; text-align: center; opacity: 0; -webkit-transition: all 0.4s ease-in-out;-moz-transition: all 0.4s ease-in-out;-o-transition: all 0.4s ease-in-out;-ms-transition: all 0.4s ease-in-out;transition: all 0.4s ease-in-out; }.box-a { opacity: 1; -webkit-transition: all 0.4s ease-in-out;-moz-transition: all 0.4s ease-in-out;-o-transition: all 0.4s ease-in-out;-ms-transition: all 0.4s ease-in-out;transition: all 0.4s ease-in-out; }
×
×
  • Create New...