Skip to content

Latest commit

 

History

History
 
 

create-a-function-to-validate-passphrase

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Great job progressing with the course. This video is a small introduction to the steps involved in submission of this task called passphrase. Many of the upcoming tasks in the levels above almost have a similar structure in task submission.

As in the lesson content the task basically expects you to implement code that would validate a passphrase. There is enough details in the lesson on what a passphrase is all about and what are the criteria to be satisfied to validate a passphrase w.r.t to this task.

So here is how you would complete and submit this task:

First step is to download the template file, in the lesson as you can see here.

ACTION: Show how to download the template file.

So you download the file, open the downloaded file in any text editor or IDE of your choice.

ACTION: Open the downloaded template file in an IDE

As you can see here there is a small function isValidPassphrase that you are expected to complete.

ACTION: Run through the file code structure

We know that You are yet to be introduced to functions and you will deal with them in detail in the upcoming level. But to just give a brief introduction, functions are a small chunk of code or procedure that would accept one or more inputs like in this case text, perform certain actions in the form of expressions, and finally return a value. You might also be curious about the module.exports statement in the file. Just to get an idea - In a real world project you would have your code split across different files or modules. This statement allows to use the function wherever you import the same. So in this case we basically use the function you write to run automated tests.

ACTION: Show the module.exports statement

You can see lot of comments here as well in the file. This is just to guide you through the task and the submission process. Please also go through the examples in the form of comments in the file. Make sure you don't change anything in the file and only where you have the comment Please fill in your code here

ACTION: Run through the comments section in the file.

So just to give you an example on how to complete a function, imagine the function here had to check if the length of the string is greater that 5. So here is how we would execute this in code. You basically write an expression to validate the same and return that value. So here is how you would execute it:

ACTION: Show how to write a code that validates whether length of a string is greater than 5.

    let result = text.length > 5;
    return result;

So that's all about checking whether the length of a string is greater than 5.

In a similar fashion, you are expected to code out the way you would validate the input text and return the boolean value based on the validity of the passphrase.

ACTION: Show another round of storing result in a variable and returning the value.

So, return is a keyword in a function, that indicate the value you return from the function.

Once that's done , save the file and move back to your lesson ,and take the Complete tab.

ACTION: Show how to navigate to the Complete tab to submit.

Upload the file that you just completed and click on Submit.

There you go! You have successfully submitted the task. Please wait for the feedback, to check for the correctness of your submission. Good luck with the task :)