Javascript Data Types/Lists
A Tech Talk on javascript data types and how to use with lists
Home | HTML | Data Types | DOM | JavaScript | JS Debugging |
ccc
Create a JavaScript snippet below with the following requirements:
- Create an object representing yourself as a person. The object should have keys for your name, age, current classes, interests, and two more of your choosing
- Your object must contain keys whose values are arrays. The arrays can be arrays of strings, numbers, or even other objects if you would like
- Print the entire object with console.log after declaring it
- Manipulate the arrays within the object and print the entire object with console.log as well as the specific changed key afterwards
- Perform mathematical operations on fields in your object such as +, -, /, % etc. and print the results with console.log along with a message contextualizing them
- Use typeof to determine the types of at least 3 fields in your object
%%js
let originalString = "Hello, World!";
let substring = originalString.substring(0, 5);
console.log(substring);
let upperCaseString = originalString.toUpperCase();
console.log(upperCaseString);
let lowerCaseString = originalString.toLowerCase();
console.log(lowerCaseString);
let includesCheck = originalString.includes("World");
console.log(includesCheck);
let num = 42;
let formattedNum = num.toLocaleString();
console.log(formattedNum);
let fruits = ["apple", "banana", "cherry"];
fruits.push("date");
console.log(fruits);
fruits.pop();
console.log(fruits);
let person = {
name: "Ninaad",
age: 16,
};
console.log(person.name);
<IPython.core.display.Javascript object>
%%html
<script src="https://utteranc.es/client.js"
repo="ninaadkiran/Ninaad-Repository2"
issue-term="pathname"
theme="github-dark-orange"
crossorigin="anonymous"
async>
</script>