Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write the code out in javascript the answer provided below is wrong. and does not work when typed out in khanacademy. Write code in javascript

image text in transcribed

image text in transcribed

write the code out in javascript the answer provided below is wrong. and does not work when typed out in khanacademy.

Write code in javascript for that will work in khan academy

?image text in transcribed

Program To Find the maximum integer in an array of positive integers var array1 [2,12,4,10, 6,81 var array2 [1,3,15,5, 7,9,11,13] var array [8] var array4 [20, 18, 16, 14,12,10,8,6]; var array5 [2,4,6,8,10,12,14] *declare function findMax which takes an array as its only parameter and returns the maximum integer in that array Algorithm: Set a local variable currentMax to the first element in the array Write a for loop from 0 to the length of the array For each element in the array: test to see if the list element at the index of the loop counter is greater than currentMax if it is, then set currentMax to the value of that array element. After the loop ends, have the function return currentMax. Set fill to black so text shows up on the screen Call findMax five times, once for each of the arrays above Print the result of each function call to the screen

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions