Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this lab you will be adding, to your resume website (1) through looping, the top job duties that you preformed at your previous employment

For this lab you will be adding, to your resume website (1) through looping, the top job duties that you preformed at your previous employment where the user specifies the number of job duties to display. Then you will (2) use an if..else ifelse statement to let the user know how large of a company you want to work for. Place all JavaScript in a single external JavaScript file.

On the work experience page, we will add a user input that asks the user to enter the number of job duties that they want to see that you preformed at your previous job. When the user clicks a button, a function will be called and will then take this input and use it to specify an index number of an array that will be the starting point of the array values (duties) to be displayed. Through looping, we will then subtract 1 from the index number until it reaches 0 and display all of the values that are associated with the index numbers that were calculated during the loop. We will be making two of these functions (one for each job), but will be copying a great deal of the code from one over to the other.

Create an input that acts as a fill in the blank for a sentence that prompts the user to enter the number of job duties they want to see.

Create a button that calls a function when clicked (the function created in the next step)

Crate a function that takes the user input and assigns the value to a variable.

Explanation of why we did step 1 c: This variable represents the number of job duties the user wants listed

Create an array with at least five job duties in it.

Explanation of step 1 d: Remember that the index starts at 0 and not 1.

In the next steps we print out the array values by referencing their associated index numbers, starting at the highest index number that we want printed and counting down. The highest index number that we want printed is the number that the user wants to be displayed minus 1.

Explanation of why we did step 1 d ii: If we did not obtain the highest index number that we want to print by subtracting 1 from the number that the user wants to be displayed and instead just used the user input as the highest index number we would actually print out the number the user wants to be displayed plus an extra. For example, if the user asks for 3, we would count down index values: 3,2,1,0. Since that is actually 4 values we will need to adjust for this in the next step by removing the first value before the loop starts.

Create a new variable and set it equal to the inputted value minus 1

Explanation of why we did step 1 e: This variable is essentially representing the first index number that we will call to be printed out, as discussed above.

Create a while loop that runs while the variable (that represents the index value that we want to print) is greater than or equal to the minimum array value.

Within the while loop have two things happen.Have the innerHTML of some element within your page be replaced with the array value that corresponds to the index number that we want printed

You specify the array value by the format arrayname[indexnumber]

Have the index subtract one from itself to count down

At this point your function should run, but it does not work properly. Only the array value at the last index is printed. To fix this, we need to concatenate the results of the loop.Create a new variable outside of the loop and set it to be equal to blank

You do this by setting it equal to

Within the loop, make this variable to be equal to itself plus the array value that we want printed.

Now change the innerHTML to be equal to this variable.

Question: What happens if we do not set this variable equal to blank first?

Copy this function over and change the name of the function, the id of the output and input, and the array values to make it work for your second job.

On the form page, we will expand on the function that takes in user input for the last assignment (asking what the salary and hours are) to let the user know if the salary is too little or else if it is almost enough, else it is a good salary . We will say, for this assignment, that if the salary is less than 20000 it is not enough, else if the salary is between 20000 and 25000 it is almost enough, and (else) if the salary is greater than 25000 the salary is enough. This JavaScript should all be done within the same function as the previous assignment.

Create an undefined variable. We do not want to assign it a value yet because we want it to have a value based on if a condition is true, so for now we will just create it and assign it a value in the next steps.

Create the ifelse if.else statement. You will need to use various operators found here: http://www.w3schools.com/js/js_comparisons.asp

The first test should test if the variable used to store the calculated salary (from the previous assignment) is less than 20000, If this condition is true, it should assign the value ". The salary is too little." to the undefined variable

The second test should test if the variable used to store the calculated salary is greater than 20000 and less than 25000 and should assign the value ". The salary is almost enough. Lets negotiate." to the undefined variable.

The last assignment should take place by default (else), if neither of the two previous conditions are met. It will assign the value ". This is a great salary for me." to the undefined variable.

Modify the statement that changes the innerHTML of the paragraph below the inputs (from the last assignment) to equal the same string as before (The salary is ) plus the salary plus this new variable (that represents if the salary is enough).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

3. Develop a case study.

Answered: 1 week ago