Click here to Skip to main content
15,888,113 members
Home / Discussions / JavaScript
   

JavaScript

 
Questionjava script Pin
noorh00727-Jun-13 7:24
noorh00727-Jun-13 7:24 
AnswerRe: java script Pin
Dennis E White27-Jun-13 7:38
professionalDennis E White27-Jun-13 7:38 
QuestionWhat do you think of this? Pin
Super Lloyd27-Jun-13 3:17
Super Lloyd27-Jun-13 3:17 
AnswerRe: What do you think of this? Pin
Dennis E White27-Jun-13 7:31
professionalDennis E White27-Jun-13 7:31 
GeneralRe: What do you think of this? Pin
Super Lloyd27-Jun-13 15:20
Super Lloyd27-Jun-13 15:20 
QuestionOnpage pagination is not working Pin
Md Shariful Islam Saful26-Jun-13 8:01
Md Shariful Islam Saful26-Jun-13 8:01 
AnswerRe: Onpage pagination is not working Pin
Dennis E White26-Jun-13 15:14
professionalDennis E White26-Jun-13 15:14 
QuestionUsing a switch statement to count variables in an array Pin
tristarterror24-Jun-13 11:09
tristarterror24-Jun-13 11:09 
Another homework assignment so please just let me know what direction I should go in.

Assignment details:
Function: counter
Parameter: An array of numbers
Returns: The numbers of negative elements, zeros, and values greater than zero in the given array.
Note: You must use a switch statement in the function.

My JS file:
C#
// Array of Numbers

var nums = new Array(-13,2,67,3,0,56,12,-41);
var len = nums.length;

for (i=0; i<len; i++) {
    var count = nums[i];
}

var count = nums[i];

//Create counter function
function counter() {

    switch (count) {
    case "negatives":
        if (count < 0) {
            document.write(count.length);
        }
        break;

    case "zeros":
        if (count == 0) {
            document.write(count.length);
        }
        break;

    case "positives":
        if (count > 0) {
            document.write(count.length);
        }
        break;

    default: {
        document.write("nothing!");
    }

}};




I am not sure where to go with this one. I know it's the switch statement that throwing me off and I am not sure if my statement for counting each variable is necessarily correct either but I feel like I'm somewhere in the correct thinking here.
AnswerRe: Using a switch statement to count variables in an array Pin
fixthebugg24-Jun-13 11:35
fixthebugg24-Jun-13 11:35 
AnswerRe: Using a switch statement to count variables in an array Pin
lmf232s24-Jun-13 12:07
lmf232s24-Jun-13 12:07 
AnswerRe: Using a switch statement to count variables in an array Pin
Manfred Rudolf Bihy24-Jun-13 20:06
professionalManfred Rudolf Bihy24-Jun-13 20:06 
QuestionVariables not showing correctly in HTML Pin
tristarterror24-Jun-13 9:17
tristarterror24-Jun-13 9:17 
AnswerRe: Variables not showing correctly in HTML Pin
dusty_dex24-Jun-13 9:45
dusty_dex24-Jun-13 9:45 
GeneralRe: Variables not showing correctly in HTML Pin
tristarterror24-Jun-13 10:16
tristarterror24-Jun-13 10:16 
GeneralRe: Variables not showing correctly in HTML Pin
dusty_dex24-Jun-13 10:55
dusty_dex24-Jun-13 10:55 
Questionhow make a skype call by getting a phone number from textbox Pin
Pasqualissimo23-Jun-13 12:20
Pasqualissimo23-Jun-13 12:20 
QuestionMSN style links Pin
Bart23-Jun-13 10:20
Bart23-Jun-13 10:20 
AnswerRe: MSN style links Pin
thanh_bkhn23-Jun-13 16:09
professionalthanh_bkhn23-Jun-13 16:09 
GeneralRe: MSN style links Pin
Bart25-Jun-13 10:22
Bart25-Jun-13 10:22 
QuestionHow to show info marker google maps when clicked in outside map? Pin
Akbarblack22-Jun-13 4:12
Akbarblack22-Jun-13 4:12 
AnswerRe: How to show info marker google maps when clicked in outside map? Pin
Dan Randolph23-Jun-13 8:55
Dan Randolph23-Jun-13 8:55 
GeneralRe: How to show info marker google maps when clicked in outside map? Pin
Akbarblack10-Dec-13 20:32
Akbarblack10-Dec-13 20:32 
QuestionShopping Cart Qty Button - I need to make it faster Pin
jkirkerx21-Jun-13 11:16
professionaljkirkerx21-Jun-13 11:16 
AnswerRe: Shopping Cart Qty Button - I need to make it faster Pin
enhzflep24-Jun-13 11:19
enhzflep24-Jun-13 11:19 
GeneralRe: Shopping Cart Qty Button - I need to make it faster Pin
jkirkerx24-Jun-13 11:38
professionaljkirkerx24-Jun-13 11:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.