write an if statement that checks if the parameter exponent is 0. If it is, return 1 (a base case).
var power = function(exponent, base){
if (exponent === 0){
return 1;
}
};
power();
It does not work, ca anyone tell why?
Problem statement:
Define isOdd function, and then define isEven function in terms of isOdd function.
My attempt is ridiculous:
var isOdd = function (x){
if (x % 2 ===0){
return isOdd;
}else{
return "is even";
}
};
var isEven = function (){
return;
};
var square = function (x) {
return x * x;
};
var cube = function (x) {
return square * x;
};
This is my shot, its not right. Please indicate or suggest the correct answear. :)
var lost = [4, 8, 15, 16, 23, 42];
var count = lost.length;
var isLost = function (n) {
for (i=lost[0]; i<count; i=lost[i+1]) {
if ( n === lost[i]) {
return "true";
}
}
return "false";
};
is it possible to in corporate array positions into the for loop? (i)
do...
Is this a legit code for printing out squares of numbers betwean 100 and 150 ? Seems to crash everytime.
for (var i=100; i<151; i*i)
{
var square = i;
console.log(square);
}
Need help :)
The general form for creating an array is:
Myarray=new arrayname();
But I don't understand wht should I type in the name of the array twice? Because I thought Myarray and arrayname is the same.
Hey everyone!
I'm building a "Deal or No Deal" calculator that estimates the odds of getting a better deal than the one presented. As you can see in the title, I'm looking for a function that will calculate the CDF. For ease's sake, please only post JavaScript code (no C,Perl,BASIC,etc.)
Homework Statement
I'm required to make a page that has the following format:
Left Frame
Items with prices and check boxes next to them
An "Update Order" button at the bottom so the order details on the Right Frame can be updated.
Right Frame
A "receipt" form with all the...
I am looking for advice on how to approach a problem. I would like to take a given number and break it into 7 parts.
For example, the function call,
BreakIntoSmallerNumbers(15);
would return the following array: [3, 2, 2, 2, 2, 2, 2]
BreakIntoSmallerNumbers(3); returns [1, 1, 1]...
Hey folks
I don't know if anyone can help with this, it should be straightforward though. I have a 2 PDF documents called Doc1.pdf and Doc2.pdf. Doc1 contains all of the odd numbered pages of a main document and Doc2 contains the even ones. I would like to merge the Doc2 even pages into Doc1...
Hi guys.
I am mechanical engineering undergraduate and we have a website. Now we want to put up an interactive calculator on our website.
So we are trying JavaScript. Though we tried writing a code for our calculator it didn't work. At this time we're getting confused because of level of...
I am trying to learn these web designing stuff on my own and am currently using
http://www.w3schools.com/html/default.asp for HTML learning... and though i am well aware of the basics ..i need to know much in depth.
So do you guys have any good 'n' free online resources to learn HTML +...
My brother is low vision and I wanted to create a web page on our local computer that will use a large cursor in JavaScript (I've heard this is possible) while being a frame around the pandora radio website, to make is easier for him to see the cursor. Alas, most of my programming experience...
I want to remove my clients browsing history every time they access new pages from my website. is there any code, i keep searching the net and i can't find one.
I am using scripting my webpage's tabs I have 5 tabs and I'd like the tab animation
I am learning to make a selected tab to be... a selected tab. I'd like this to be done in css
I'd like the mouse pointer not to be changed into a hand when the mouse is over the selected tab. That's it I mean...
Homework Statement
I'm supposed to write a program that upon clicking a command button generates a random number, and displays 1 of 7 images that is associated with the random number generated.
Ive been at this for a few hours and can't get the image to change.
EDIT:
Upon further testing it...
can one write a javascript bookmark that will print a single unicode character (like a smiley face or a math symbol) to the clipboard (or better still straight to the cursor position)?
how about print something like (SUB) to the clipboard then append what is highlighted to the clipboard then...
Is it possible with javascript to take one article from blog A, one article from blog B, one article from blog C, and show them all together in one big table, with one article per table cell?
Even better, is it possible to mix blogs as above but without duplicating content on an intermediate...
I have some divs on a web page, with the class name "hans" which I would like to hide with JavaScript when the page loads. The reason I have it set up this way is so that the user can reveal the div's by clicking a link, but if JavaScript is disabled, the div's will be displayed by default...
I'm looking at this site that I may need to modify. It was built in Frontpage.
I'm not familiar with FP. There's a block of code the top like this:
<SCRIPT type="text/javascript"><!--...
I was wanting to have a simple copy of the Deep Impact countdown on my signature in another forum. I've really been racking my brain trying to figure this out, and to no avail.
http://www.space.com/deepimpact/
any help would be GREATLY appreciated.
B. Elliott
When my users click a button or a link etc, to get out or to get known what I would like to tell them, they will always see "Javascript Application" and below it is my message written.
Now, I would completely be able to GET IT OUT OFF MY MESSAGEBOX, that TITLE...How can I make this ? Could you...
I'm having trouble sumbitting a form using javascript. The form has a submit button (type=button) that used to be type=submit. i have change it's properties so that it now calls a function that later submits the information. the problem I'm having is that when i click the submit button the...