Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  • Thread Tools
  • Rate This Thread
  1. #1
    New to the CF scene
    Join Date
    Apr 2016
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript Program

    I'm just super confused on how to do this and am not sure where to post it so sorry if this is the wrong place and if anyone can help me start it, that'd be great.

    Write a program that utilizes a function that has two parameters, num and letter. The function should utilize a for loop that continually prompts the user to enter strings until the loop has iterated exactly num times. As the user enters each string, the function should determine if the string just entered contains two or more of the characters specified in the letter parameter. After the loop has finished the program should return the number of strings that contained two or more of the specified letters. Include code to demonstrate the correctness of your program.

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,303
    Thanks
    30
    Thanked 864 Times in 862 Posts
    You should tell use what or where you are stuck and give us your code.
    Are you having trouble...

    writing a function that has two parameters?
    Code:
    unction Aname(num, letter){...}
    Or a for loop iterating exactly num times?
    Code:
    for(var x=0; x<num; x++){...}
    Or returning the number of strings that contained two or more of the specified letter?
    Code:
    str.indexOf(letter);
    Last edited by sunfighter; 04-28-2016 at 02:58 AM.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.

  3. Users who have thanked sunfighter for this post:

    aaron123232 (04-28-2016)


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •