Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8135013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:15:56+00:00 2026-06-06T10:15:56+00:00

Got a simple Javascript program here to accept and check a password. It should:

  • 0

Got a simple Javascript program here to accept and check a password. It should:

  1. Ask you to enter a new password

  2. Check the strength of the password which outputs a message of either weak or strong based on a length of <6 or >6.

  3. Get you to re enter this password to enter the ‘system’

  4. Give you simple prompts or 2 random letters if the password is not correct.

Everything works except the strong/weak checker. It has a problem getting the length of passwordEntry since it apparently doesn’t exist as an entity.

Any ideas would be much appreciated

var pass;
var main = function(){
strengthCheck((prompt("Please Choose a New Password to Begin"));
}

var strengthCheck = new function(passwordEntry){
score = 0;
// adds to the score variable depending on the length of the password
if(passwordEntry.length > 6{
score=(score+1);
}
//reads messages back stating how strong password is based on length
if(score=0){
console.log("Your Password is Weak");
}
else if(score=1){
console.log("Your Password is Strong");
}
var passContinue = prompt("Do you want to continue with this password? Yes or no?")
if(passContinue === "no" ||  passContinue === "No"{
main();
}
else{
pass = passwordEntry;
console.log("Your new password has been changed to " + pass);
passwordChecker(prompt("Thank You. Please Enter Your Password Below"));
}
}

var passwordChecker = function (attempt){
if(attempt == pass){
    console.log("Correct password. The system has logged you on");
}
    else{
    //if the password is wrong, runs the incorrectpassword() function
        console.log("Incorrect Password");
        IncorrectPass();
        }
    }
}

var IncorrectPass = function (){
var clueanswer = prompt("Do You Want A Clue");
if(clueanswer === "Yes" ||clueanswer === "yes"){    
console.log("I will give you two random letters");
// takes two random locations from the string array and reads them back
var randarray1 = Math.floor((Math.random()*7)+1);
var randarray2 = Math.floor((Math.random()*7)+1);
var randletter1 = pass[randarray1];
var randletter2 = pass[randarray2];
console.log(randletter1+" "+randletter2);
passwordChecker("Please try entering your password again");  
}
    else{
        console.log("GoodBye");
    }
}

main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:15:58+00:00Added an answer on June 6, 2026 at 10:15 am

    Change this…

    var strengthCheck = new function(passwordEntry){
    

    to this…

    var strengthCheck = function(passwordEntry){
    

    When you use new, you’re not using it to create a new function. You’re using it to call the function as a constructor, which will return an object. (An empty object in your case.)

    Also, you have many syntax errors in your code. Use a code validator like http://jshint.com as well as a beautifier like http://jsbeautifier.org to clean up your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a simple JavaScript regex check (written by other developer) that works perfectly
Hello i'v got simple program which is couting characters in given text until line
Seems like a very simple question here: I've got a program where someone is
I've got a very simple javascript calculator here but it doesn't seem to be
I've got a simple javascript program that I'm using for a project. To explain
new with javascript here. I have a simple form that takes what the user
I've got a simple JavaScript statement that reads a string and fires off a
I've got a simple shell script which synchronizes Google Calendars for quick local access.
I got a simple question about jQuery but rather javascript approaches in general... Is
iv got a really simple javascript question. Ill be using query for parts of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.