Practice JS Lab Practical

Problems 1 and 2 Implement the two specified functions. Get this and you have a B-.


/*
* This returns a string with the odd-indexed charcters of s removed.
*   Examples
*   cutHalf("doggerel") = "dgee"
*   cutHalf("holey cow") -> "hlycw"
*/
function cutHalf(s):
{
    return ""
}
/**
* s is a string
* n is a nonnegative integer, n < s.length()
* returns a string with the last n characters lopped off.
*    Examples
*    lopov("cowabunga", 2) -> "cowabun"
*    lopov("phew", 0) -> "phew"
*    lopov("katzenjammer", 6) -> "katzen"
*/
function lopov(s, n)
{
    return ""
}

Problems 3 and 4 Instruction are embedded in the HTML. One solution gets you a middle B, the other A-/B+


<!doctype html>
<!--Author: Morrison-->
<!--Date: 2021-11-07-->

<html lang="en">
<head>
<title>middle</title>
<meta charset="utf-8"/>
<link rel="stylesheet" href="middle.css"/>
<script src="middle.js"></script>
</head>
<body>
<h2>Problems 3 and 4</h2>

<p><strong>Problem 3</strong>
These three divs turn State Red (#CC0000) when they are entered and 
return to white when exited.</p>

<div>
</div>
<p></p>
<div>
</div>
<p></p>
<div>
</div>
<p></p>

<p><strong>Problem 4</strong>
Every time you click on this button, the count of clicks it displays
should go up 1.  Hint: The creative use of a span cna make this work, but
it's not the only way.<p>

<p class="display"><button>Clicked: 0</button></p>
</body>
</html>

Here is your stylesheet.


/*Author: Morrison*/
/*Date: 2021-11-07*/

h1, h2, .display
{
    text-align:center;
}
div
{
    margin-left:auto;
    margin-right:auto;
    border:solid 2px green;
    height:100px;
    width:200px;
}

Here is skeleton JS.


/*Author: Morrison
Date: 2021-11-07  */
addEventListener("load", main);
function main()
{
}

Problems 5 and 6 These are the A range problems.

In the beginning you see this.

starting appearance

Click a few times and you see little dookbloo 50X50 squares. Dookbloo is #001A57.

clicked a few times to get squares

Now click the button labeled "cross" and click in the canvas. You will get a cross centered at the mouse click. The two members are 50 pixels wide and spand the height and width of the canvas.

clicked on the cross button to get crosses

Clicking on the buttons marked "square" and "cross" controls the shape you get. The crosses are Carolina blue, #99BADD.

Useful Hint You will find it useful to create a variable called squaring, which is true at the start and which becomes true whenever the square button is hit. Hitting the cross button makes squaring false. This causes crosses instead of squares to be put to the canvas.