Skip to content

KidiIT/Clearing-SetTimeout-with-JavaScript

Repository files navigation

Clearing SetTimeout with JavaScript

To begin with, I want to start by thanking everyone for the massive review and love on my works. your reviews do motivate me to develop and solve more tremendous works with JavaScript and some other awaiting programming languages. however, lets get to the wonderful knowledge and experience I'm going to share with the community today. Futhermore,the following will explain and give you an indepth understanding about this project and how to use it at your various places of work.

How to use and the purpose of this project:

  1. This project was intensively developed with the motive of ensuring prevention and improvement of proactive security software for the protection of an organization infrastructure.

  2. Before rolling on the real deal, an indepth knowledge of html,css and Javascript is needed to be able to understand how to clear settimeout funtion with Javascript because it's kinda tricky if this is your first time here.

  3. First thing first, make sure you've created or will create a nice template on your html file to be able to fit in on this project.

  4. After which, link your Js.file with your html file. then use an attribute selector to make it more easier for you to get your elements to your Js.file at once. as seen on my time.js file. moreover, if you're new in programming then you've nothing to worry about because I'll stick with you throughout this project or problem solving because it's a very tricky one to work on alone. this will automatically lead us to the 5th step.

  5. in addition, the fifth step should be an easy one for everyone. after you must've selected the required element from your html file. then create a constant variable by using the word "LET" and assign a value to it. remember assigning a value at this point depends on how and when you want the security protocol or the settimeout to execute on your program. as seen on my time.js, I used 200 as my value and it's applicable on your end if you wish.

  6. the next step is where a reaquired function timer() was created. don't worry if you don't know how to create a function in Javascript, you're 100% free to access and use my work template. on that note, the timer function will execute whenever the initial function is been called outside the gobal function. don't get afraid yet alright hahaha!. alright, A global function is a function that is defined outside of a class or struct and can be accessed from anywhere in the program. after which assign your input element.innerHTML = time.

  7. in this step, you'll create another constant veriable which will be assign to setinterval function and set the time you want as a timer. it's usally caculated in sec which is 1000 = 1sec. haven't understood how to assign and store the setinterval function to a varibale which I named as timing on my time.js file.

  8. The setTimeout is a function method which will perform the timeout task and clear the time you set on your initial variable as seen on my time.js mine was set as 200. and these can only be done once so be careful when setting your varibale.

  9. on the next, create a settimeout function after or on the next line of your code and inside your function, use the key word "clearTimeout(timing)" to store the veriable you assign to the setInterval function which is "timing" on my end.

  10. lastly, you can clear the timer function by using an assignment operator mutiply(*), by mutiplying the variable time(value) which 200 * 1000(timer) to be able to iterate and perform its expected function at the right time. I presumed that we must've assimilated alot today.

Just a recap for quick understanding, to solve this problem you need two responsive functions which are the setinterval function that take care of the timer while the settimeout function is responsible to execute any function for clearing of the time that's been assign by the programmer at the initial stage.

Furthermore, In reference to develop a proactive security software that will be used to protect an organization infrastructure. this is where the knowledge of this project will be appplicable and used. For instance, If an entry-level cybersecurity analyst personnel is been assign a task to develop a proactive software that will protect the organization from their potential threats, risks and vulnerabilities.that been said, the use of the setinterval function to set a timer and the SetTimeout function to clear the time of which the program will execute its functionality on the software will be very effective and essential in validating and creating a software that will protect the financial aspect of an organization, by detecting and clearing any found threats, risks and vulnerabilities that will harm the security standard of an organization. Most importantly, It'll protect the company's reputation by making them to meet up with the regulatory policy in cybersecurity. also,it can help to prevent and protect the organization from any potential threats or risks from happening at the first place. if deployed intensively with well stated algorithms and functions when developing your software.

In conclusion, I've decided to throw more light or points on the last part of my project.which is clearing SetTimeout with javascript function. however, enlighting us more on how to apply and use the EventListner on this project or any work you want will be a great one to look into and this is what happen on the last part you need to note:

  1. I created an EventListner function "oninput" which means my SetTimeout function will start tracking the time whenever a user start typing on the "input Box". The user have 200 sec to type on the input box. after 200sec if you're unable or fast enough to manage the time given then you'll be kicked out of the session. and you can start another session to test how fast you can type the word "HELLO WORLD THIS IS TYPING".
  2. secondly, I used "FOR LOOP" to iterate the word to type on the input box.
  3. on the next step, I assign a constant element to the word to type variable and I passed an "IF STATEMENT" which is If the element is equal to e.target.value[i]. then console.log(element) which is "HELLO WORLD THIS IS TYPING".

Lastly, I want to use this opportunity to give y'all heads up on how happy and delighted I'm at the moment about the progress we've made on this repo. I won't have come this far without you guys. my warmest gratitude goes to each and everyone of you. that been said, this repo is about 964+ views with 212 clones. I'm still surprised about the views and clones. I hope we achieve more on my next repo/project guys. see y'all soon.