31-Use Bracket Notation to Find the First Character in a String
// ExamplevarfirstLetterOfFirstName="";varfirstName="Ada";firstLetterOfFirstName=firstName[0];// SetupvarfirstLetterOfLastName="";varlastName="Lovelace";// Only change code below this linefirstLetterOfLastName=lastName[0];
32-Use Bracket Notation to Find the NthtoLast Character in a String
// ExamplevarfirstName="Ada";varthirdToLastLetterOfFirstName=firstName[firstName.length-3];// SetupvarlastName="Lovelace";// Only change code below this linevarsecondToLastLetterOfLastName=lastName[lastName.length-2];
33-Word Blanks
34-Store Multiple Values in one Variable using JavaScript Arrays
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;
// Your code above this line
return result;
}
// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
// Example
var ourArray = ["John", 23];
// Only change code below this line.
var myArray = ["John", 25];
// Example
var ourArray = [["the universe", 42], ["everything", 101010]];
// Only change code below this line.
var myArray = [["John", "smart"],["Dudao", "stupid"]];
// Example
var ourArray = [1,2,3];
var ourData = ourArray[0]; // equals 1
// Setup
var myArray = [1,2,3];
// Only change code below this line.
var myData = myArray[0];
// Example
var ourArray = [1,2,3];
ourArray[1] = 3; // ourArray now equals [1,3,3].
// Setup
var myArray = [1,2,3];
// Only change code below this line.
myArray[0] = 3;
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// Only change code below this line.
var myData = myArray[2][1];
// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.push(["happy", "joy"]);
// ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]
// Setup
var myArray = [["John", 23], ["cat", 2]];
// Only change code below this line.
myArray.push(["dog", 3]);
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]
// Setup
var myArray = [["John", 23], ["cat", 2]];
// Only change code below this line.
var removedFromMyArray = myArray.pop();
// Example
var ourArray = ["Stimpson", "J", ["cat"]];
removedFromOurArray = ourArray.shift();
// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].
// Setup
var myArray = [["John", 23], ["dog", 3]];
// Only change code below this line.
var removedFromMyArray = myArray.shift();
// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]
// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();
// Only change code below this line.
myArray.unshift(["Paul", 35]);
// Example
function ourReusableFunction() {
console.log("Heyya, World");
}
ourReusableFunction();
// Only change code below this line
function reusableFunction() {
console.log("Hi World");
}
reusableFunction();
// Example
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5
// Only change code below this line.
function functionWithArgs(num1, num2){
console.log(num1 + num2);
}
functionWithArgs(1,2);
functionWithArgs(7,9);
// Declare your variable here
var myGlobal = 10;
function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5;
}
// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}
function myLocalScope() {
var myVar = 'use strict';
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
// Now remove the console log line to pass the test
// Setup
var outerWear = "T-Shirt";
function myOutfit() {
// Only change code below this line
var outerWear = "sweater";
// Only change code above this line
return outerWear;
}
myOutfit();
// Example
function minusSeven(num) {
return num - 7;
}
// Only change code below this line
function timesFive(num) {
return num * 5;
}
// Example
var changed = 0;
function change(num) {
return (num + 5) / 3;
}
changed = change(10);
// Setup
var processed = 0;
function processArg(num) {
return (num + 3) / 5;
}
// Only change code below this line
processed = processArg(7);
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var firstArrNum = arr.shift();
return firstArrNum; // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
function welcomeToBooleans() {
// Only change code below this line.
return true; // Change this line
// Only change code above this line.
}
// Example
function ourTrueOrFalse(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}
// Setup
function trueOrFalse(wasThatTrue) {
// Only change code below this line.
if(wasThatTrue){
return "Yes, that was true";
}
return "No, that was false";
// Only change code above this line.
}
// Change this value to test
trueOrFalse(true);
// Setup
function testEqual(val) {
if (val == 12) { // Change this line
return "Equal";
}
return "Not Equal";
}
// Change this value to test
testEqual(10);
// Setup
function testStrict(val) {
if (val === 7) { // Change this line
return "Equal";
}
return "Not Equal";
}
// Change this value to test
testStrict(10);
// Setup
function testNotEqual(val) {
if (val != 99) { // Change this line
return "Not Equal";
}
return "Equal";
}
// Change this value to test
testNotEqual(10);
// Setup
function testStrictNotEqual(val) {
// Only Change Code Below this Line
if (val !== 17) {
// Only Change Code Above this Line
return "Not Equal";
}
return "Equal";
}
// Change this value to test
testStrictNotEqual(10);
function testGreaterThan(val) {
if (val > 100) { // Change this line
return "Over 100";
}
if (val > 10 ) { // Change this line
return "Over 10";
}
return "10 or Under";
}
// Change this value to test
testGreaterThan(10);
function testGreaterOrEqual(val) {
if (val >= 20) { // Change this line
return "20 or Over";
}
if (val >= 10) { // Change this line
return "10 or Over";
}
return "9 or Under";
}
// Change this value to test
testGreaterOrEqual(10);
function testLessThan(val) {
if (val <25 ) { // Change this line
return "Under 25";
}
if (val < 55 ) { // Change this line
return "Under 55";
}
return "55 or Over";
}
// Change this value to test
testLessThan(10);