hisoka

Members
  • Content count

    477
  • Joined

  • Last visited

Community Reputation

2 Neutral

About hisoka

  • Rank
    Member
  1. There are things I cannot understand in this code : function subset(arra, arra_size) { var result_set = [], result; for(var x = 0; x < Math.pow(2, arra.length); x++) { result = []; i = arra.length - 1; do { if( (x & (1 << i)) !== 0) { result.push(arra[i]); } } while(i--); if( result.length >= arra_size) { result_set.push(result); } } return result_set; } console.log(subset([1, 2, 3], 2)); The Math.pow() function returns the base to the exponent power, that is, baseexponent. But I do not understand why it is used in the code above ? what is the purpose of it ? and why it is used in combination with arr.length what does this mean : i = arra.length - 1; why bitwise and shift operators are used here in this code ? for what purpose ? (x & (1 << i)) !== 0) what is the purpose of making an empty array ? result = [];
  2. ok I understand the items inside the array are numbers so why we need to convert them into numbers ??? and therefore why do not we simply write : total += input[i]; ?
  3. it is a good idea but in a text editor , I do not see my errors when I run the code in the browser because they are not shown like in scratchpad or web console . if there is an error I got only a blank page . that , of course , makes it very hard - at least for a beginner like me- to notice my errors and therefore correct them . Moreover I need , every time , to save my code as HTML and then launch it in the browser . No good thing
  4. you said Number convert the string into numbers so why here in this code I got NAN function sum() { var total = 0; var letters = ["A" , "B"]; for(x = 0 ; x < letters.length ; x++) { total += Number(letters[x]); } document.write(total); } var x = sum(); if you run it in the browser you will get NOT A NUMBER OR NAN
  5. function sum(input){ if (toString.call(input) !== "[object Array]") return false; var total = 0; for(var i=0;i<input.length;i++) { if(isNaN(input[i])){ continue; } total += Number(input[i]); } return total; } console.log(sum([1,2,3])); console.log(sum([100,-200,3])); console.log(sum([1,2,'a',3])); In this code I do not understand what is total += Number(input[i]); Number ????
  6. I looked for a tool inside mozilla - by clicking Menu then developer - in which I can write a code composed of both javascript and html . Unfortunately , I could not find in the developer any tool that accepts both html and javascript together . web console and scratchpad do not accept html . Is there - may be - a tool inside Mozilla firefox or an extension that I overlooked and that could help me write a code of both html and javascript because I do not want to download a javascript developer tool from google
  7. Thank you , I will try to put more efforts before asking the question
  8. could you please tell me what do some of these above mean ? what does Number of this disk mean ? what does Disk where central directory starts mean ? what are central directory records ?
  9. I already did . However I still do not understand what are the additional hex values after 50 4B 05 06
  10. and what represent these additional hex values after 50 4B 05 06 00 00 00 00 02 00 02 00 6F 00 00 00 84 09 00 00 00 00 ??
  11. Hello glad to be again in w3schools forum when I opened a zip file in hex editor , I noticed that after the end of the file , there are additional hex values . For example in a zip file I opened in a hex editor there was like this : 50 4B 05 06 00 00 00 00 02 00 02 00 6F 00 00 00 84 09 00 00 00 00 50 4B 05 06 hex values represent the end of the zip file . However , I do not understand what represent these additional hex values after the end 00 00 00 00 02 00 02 00 6F 00 00 00 84 09 00 00 00 00 ??
  12. Could you please tell me how does exactly a missile launch code work ? I have a website here which is of course fake https://whitehouse.gov1.info/launch/launch.html and I saw codes like this : pyHAvqTp3Mxye8vscUGr+92wvuhK6eyL9QBseQ4gsX3Fcnr2xO 9cMJHoSdEv98hVymwhLsOgLzigJHPTfxA0Ani7EWNaZx1hLaRm pyHAv2KZ9gRLgLtwb4spOh0Xb1cFjsZ3tcbo6CnuUT+wOy74p7 mQINBE+UYy0BEADeUhQF1JVfDU9/OAvWD3FajAyQPjAeiOoVRfukM0L8qFQCieCN pyHAvqTp3Mxye8vscUGr+92wvuhK6eyL9QBseQ4gsX3Fcnr2xO 9cMJHoSdEv98hVymwhLsOgLzigJHPTfxA0Ani7EWNaZx1hLaRm pyHAv2KZ9gRLgLtwb4spOh0Xb1cFjsZ3tcbo6CnuUT+wOy74p7 mQINBE+UYy0 how does the whole process work?
  13. var x = document.anchors ; for ( var i = 0 ; i < 5 ; i++) { console.log(x[i]); } gives as a result and even var x = document.anchors ; for ( var i = 0 ; i < 5 ; i++) { alert(x[i]); } gives undefined I do not know how to get the result . Any help
  14. finding HTML objects : document.anchors I would like to enumerate the first 5 <a> elements using for loop but I failed : var x = document.anchors ; for ( var i = 0 ; i<=5 ; i++) { console.log(x);} This what I got HTMLCollection [ ] HTMLCollection [ ] HTMLCollection [ ] HTMLCollection [ ] HTMLCollection [ ] I would like to get the first 5 elements . Any hint ?
  15. Now to understand : document.getElementById(id).onclick = function(){code} I wrote this : <html> <body> <p id="here">w3schools.invisionzone.com</p> <script> function change() { var x = document.getElementById('here'); x.style.color = "red"; } </script> <form> <button type="button" onclick="change()" >Click Me!</button> </form> </body> </html>