Arrays - Day6 - Practice1
by grettynebraska
HTML
<div id="inputDiv" class="left">
Input:<br/>
<textarea id="inputArea"></textarea>
</div>
<div id="buttonDiv" class="left">
<input type="button" id="runButton" value="Run Program">
</div>
<div id="outputDiv" class="left">
Output:<br/>
<textarea id="outputArea"></textarea>
</div>
CSS
.left{
float: left;
}
.right{
float: right;
}
.clear{
clear: both;
}
.hidden{
display: none;
}
.hint{
font-size: 75%;
font-style: italic;
}
#inputDiv, #outputDiv{
width: 40%;
padding: 10px;
}
#buttonDiv{
width: 10%;
text-align: center;
padding-top: 30px;
}
#runButton{
padding: 5px;
}
#inputArea, #outputArea{
width: 100%;
height: 200px;
}
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 40px;
height: 15px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 11px;
width: 11px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #099;
}
input:focus + .slider {
box-shadow: 0 0 1px #099;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
JavaScript
//Main function
function main() {
var myList = [1,2,3,4,5,6,7];
myList[0] = "start";
myList[6] = "end";
print(myList);
var numbers = [1,2,3,4,5,6,7,8,9,10];
for(var i=1; i< numbers.length; i++) {
if([i] % 2 == 0) {
numbers[i] = numbers[i] * 2;
} else {
numbers[i] = numbers[i] * 3;
}
}
for(var i=1; i< numbers.length; i++) {
print(numbers[i]);
}
}
//encoding function
function encode(inputArg) {
var output = "";
for(var i = 0; i < inputArg.length; i++){
//we want the value of i to become two plus the value of j
alphaMatch = alpha.indexOf(inputArg[i]);
alphaMatch += 2;
output += alpha[alphaMatch];
} print(output);
return output;
}
//decoding function
function decode(outputArg) {
var decodeOutput = "";
for(var i = 0; i < outputArg.length; i++){
//we want the value of i to become two plus the value of j
alphaMatch2 = alpha.indexOf(outputArg[i]);
alphaMatch2 -= 2;
decodeOutput += alpha[alphaMatch2];
} print(decodeOutput);
}
function practice31() {
var input = readLine();
if (input.startsWith("a") || input.startsWith("e") || input.startsWith("i") || input.startsWith("o") || input.startsWith("u")) {
print("true");
} else {
print("false");
}
}
function practice30() {
var input1 = readNumber();
var input2 = readNumber();
var output = 1;
for (input1; input1 < input2; input1++) {
output = output + input1;
}
print(output);
while (input1 < input2) {
output += input1;
input1++;
}
print(output);
}
function practice29B() {
var input = readLine();
if (input.length > 5) {
if (input.length % 2 == 0) {
print(input.substring(0, input.length / 2));
} else {
print(input.substring(input.length / 2));
}
} else {
print(input);
}
}
function practice29A() {
var num = readNumber();
if (num > 5) {
print(num);
}
}
/* print(line1 + line2);
print(line1 - line2);
print(line1 *...