Round a number to a specified number of digits. You may not use toFixed() method. The number of digits could be 2, it could be 8, etc. Your function should work with any possible number. There are many ways to solve this.
I solved it... but not the logical way. =(
var decimalPlace:uint = Math.pow(10, prec); // get the decimal place needed to perform the calculation var result:Number = Math.round(decimalPlace * num) / decimalPlace;
Yeah I'm going to. xD I would love to know how to do it the logical way without Math.pow()... I'm just going to ask my instructor tomorrow how to do it that way.
Its a Programming Fundamentals class so there trying to get us to come up with our own stuff (think like a programmer) instead of using most built-in code.
@Loktar i'm becomming more and more interesting in trying to take this use js and canvas to turn an image into css for making background animations. i wonder what the performance of canvas vs keyframe animations is :/
I used to program on the c64 making games, then moved on to visual basic and blitzbasic/3d, then once I hit javascript i was like hmm how can I make images
discovered the canvas tag and away I went
but yeah most of my hobby programming has been graphical/game related
so its just random stuff I picked up over the years
renderer.src = screen;
renderer.onload = function() { // place the change of the text to correspond with the change of the image.
caption.childNodes[0].nodeValue = caps;
renderer.alt = caps;
};
I know the fundamentals, some programming patterns, OOP and how to make my own stuff... but my biggest downfall is... applying advanced mathematics to programming. >,< I cannot seem to do it...
can't manipulate image data of an image if it is from another domain. so you get the base64 of the image with a server component and send that back to the client (or extension as the case be)
Hopefully one day I will get better understanding of this stuff. I should buy a c64...
Maybe it could help force me to program better.
for (var i = 0, num = 200 / 10; i <= num; i+=.01) {
var x = i * 10; var y = Math.sin(i) * Math.sin(i) * 50 + 50;
// use a color triad of Microsofts million dollar color p.buffer[p.index(Math.floor(x), Math.floor(y - 10))] = p.color(0x00, 0x44, 0xcc); p.buffer[p.index(Math.floor(x), Math.floor(y))] = p.color(0xcc, 0x00, 0x44); p.buffer[p.index(Math.floor(x), Math.floor(y + 10))] = p.color(0x00, 0xcc, 0x44); }
May someone please see this fiddle: jsfiddle.net/rqerz/3 I think there is a bug with jQuery countdown. When the onExpiry happens, it needs tab to switched before it gives the alert. Please test there, and tell me what you got.
@loktar like am getting a variable through an innerhtml dynamically and display at one part of my code so as another in two different functions can we get the sum or product of both of em
yeah like function function1() { some code }function function2() { some code }
the "Verbally Readable !== Quicker Comprehension" arguement on http://ryanflorence.com/2011/case-against-coffeescript/ is really potent and interesting. i and im should other would be very interested in evidence arguing against this. there's clear evidence for this and i believe it. ppl naturally...
@chx101 you need to attach the event to the new element after it is created but before it is added to the page - the predefined event handlers will only attach to the elements that are on the page when they run
I sat down to write a demo HTML5-ish page that lets a user to perform following operations on a canvas - draw lines, draw a filled rectangle, and reset the canvas. Each operation is represented by a button, clicking on which the operation is carried out.
My initial attempt ended up as a mingled ...
I currently have some code that checks if squash and tennis scores are valid, both in javascript and PHP.
This results in 4 blocks of code existing, 2 languages * 2 sports, which does not scale well should any extra sports come around, or extra languages...
How can one describe the valid scores...
Hello. I have a line <a href="#" onClick="javascript:vidSwap('http://www.vorbis.com/music/Epoq-Lepidoptera.ogg'); return false;">open</a> which calls this: function vidSwap(vidURL) { var myVideo = document.getElementsByTagName('video')[0]; myVideo.src = vidURL; myVideo.load(); myVideo.play();
}
and I don't get the logic of accomplishing this thru that: I wanna browse thru the file system and then play the video in the browser using a custom html5 webplayer
I think I can do this by first of all loading the content source from the anchor tag onto an array and then passing that array index as a src to the video player. Is that possible?
yup, i want to change the video, download the source on your system, click on the open, it will load the other video from the url that I have specified in the code.