Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by SnakesBite101

  1. I understand how Ternary operators work but i came across an inline one and im trying hard to figure out what each operation is doing. Can anyone please explain this to me: var hadRelations = false,isSure = false, presidentQuote = hadRelations ? "Did not have relations" : isSure ? "Did not have relations" : "I admit"; "I admit" is the value returned 1st i dont understand why they use "," instead of ";" to terminate variable definitions. But what is the Ternary doing? i don't understand the use of the first two strings in the operation. What is the concept here, what would make the return valu
  2. thanks. ive caught so many random statements about html5 being able to do this and that, like programing etc.. and it started to scare me:( thanks for explaining it
  3. can i stop that happening by using max-height, max-width etc..? i used position relative or absolute. is fixed a better choice?ill definately not use those types of buttons again. just checking to see what i could do. ill start a new page and try and make it look a lot more readable and well thought out. thanks
  4. in your opinion could u please tell me which 1 is better to learn 1st. php or Javascript? also is learning HTML5 a lot harder to learn than 4?
  5. hey guys. W3schools has taught me everything i know. after HTML, they advised CSS, then Javascript. Even though i find JS hard, i believe i have past the beginner level, but still Im just not satisfied with my skill with JS yet. i have stalled. i don't believe im progressing anymore. w3schools advised PHP after JS. An old friend of mine said Javascript is better learned AFTER or with PHP but not by itself. He's reasoning is i need server stuff to work with. That if i learn JS alone, there are certain aspects of JS I won't be able to put into practise, it will just be memory knowledge i.e AJAX.
  6. hey many thanks for explaining it to me. The code is definately a lot clearer for me now.
  7. Hey guys, i need a little help understanding cookies. I feel the cookie tutorial on the site was rather poorly explained. i'm trying really hard to make sense of it, i'm sure it's a small detail im missing. http://www.w3schools.../js_cookies.asp it starts off with this code: function setCookie(c_name,value,exdays){var exdate=new Date();exdate.setDate(exdate.getDate() + exdays);var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());document.cookie=c_name + "=" + c_value;} Most of this is clear, but can someone tell me what a cookie value is? They explained c_name
  8. hey sorry i didnt see your last message. sure i would love some help to fix that issue. i havent even touched or modified the site since then as ive been just studying Javascript. With the bad design of the site, i probably won't touch it again, but it would be nice to know hot to fix the issue
  9. For instance i know Math.random() returns a random number between 0 and 1i know Math.floor(Math.random()*11) returns a random # between 0 and 10 but say i wanted the random number to start from 5 and not 0. how do i go about doing this?
  10. quick question. would this also solve the issue: if typeof obj !== null;
  11. ok thanks thats clear. i just tried it on firefox and it worked. thanks ill be double checking on 2 browsers from now on
  12. i have a question. i did a quick person array. ive used both a for and for in loop to loop through it. they give me the same results. If i alert the results, i get a separate alert for each element in my array. but if i use document.wrtie, my code only writes out the 1st element, "john". can anyone tell me why this is happening: <!DOCTYPE html><html><body><button onclick="myFunction()">Try it</button><script type="text/javascript">function myFunction(){var x;var person=["John","Pete","Ray"];for (x in person){document.write(person[x]);//alert works fine but n
  13. thanks guys. hey on 6) you are right. in my 1st post i said that the video is whats making me not complete the site. which is why i put the yellow border, bottom of the page container to show how that video went outside of it. the containers height is 100% so i dont know why this happened. margin and padding doesnt fix it. thank you for your points i will make all changes. very tough to spend time on the page because im trying to learn javascript, HTML5 and CSS3 at the same time:(
  14. hey guys its been a few days, no one wants to comment on my incomplete test page... please i will really value your opinions
  15. let me try to explain: function sumValues(val1, val2, val3) {if (val1 === undefined) {val1 = 0;} if (val2 === undefined) {val2 = 0;} if (val3 === undefined) {val3 = 0;}return val1 + val2 + val3;} the function is expecting 3 values(numbers) to be passed in for addition. like this, var addnums = sumValues(3, 5, 6) .. the IF statement means if a number is left out. like if i only pass val 1 and 2 but not 3. var addnums = sumValues(3, 5) <--- if val3 === undefined {value3 = 0}. they want me to use the default operator instead of the IF statement to set the value of any arguments that are left
  16. im not sure. how the function would work wasnt clear. the whole code wasnt written. it was a task in a tutorial. the aim of what i was instructed to do is to learn to replace if statements with either ternary or default operators. they gave 1 example, then set this task. here's the example: if (min === undefined) {min = 1;}// becomes simplymin = min || 1; var contactInfo;if (email) {contactInfo = email;} else if (phone) {contactInfo = phone;} else if (streetAddress) {contactInfo = streetAddress;}// is greatly shortened tovar contactInfo = email || phone || streetAddress;
  17. thanks ingolme. thats very clear now
  18. 3 values are going to be passed into the function and calculated. like : var addnums = sumValues(3, 5, 6) <-- sumValues is the name of the function and it returns addition... return val1 + val2 + val3;
  19. hey guys can someone please tell me what this attribute means or does? <textarea wrap="virtual"> also what does the length property actually do in an input field? if i have length="2" i can still type more than 2 characters. and i believe the rows="8" is actually what defines the actual length of an input field?
  20. looks simple but i cant get it: // this function uses the if blocks to // handle the optional parameters. // Change it to use the default operator instead. function sumValues(val1, val2, val3) { if (val1 === undefined) { val1 = 0; } if (val2 === undefined) { val2 = 0; } if (val3 === undefined) { val3 = 0; } return val1 + val2 + val3;}
  21. hey i fixed the issue. the link is now up above ^^^ the results are best in Explorer which is what i tested the page on. firefox messes up my ad on the bottom right by not giving it the margin-top i added. any ideas why? thanks all
  22. at step 2, its asking me to choose one of their templates. is there a way to ignore this step?
  • Create New...