Javascript Code Challenge
How do I make an javascript code challenge?
What is a javascript code challenge? How do you make a javascript code challenge? This script and codes were developed by Thomas Weld on 09 January 2023, Monday.
Javascript Code Challenge - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Javascript Code Challenge</title>
</head>
<body> <h2>See Console for Results</h2>
// write a method names()
// which takes a string of
// comma-separated names
// (first and last) and then
// returns an object where each
// firstname is a key, and each
// lastname is a value
//
// i.e. names("George Washington, John Adams, Kanye West")
// .. --> {
// George: "Washington",
// John: "Adams",
// Kanye: "West"
// } <script src="js/index.js"></script>
</body>
</html>
Javascript Code Challenge - Script Codes JS Codes
// write a method names()
// which takes a string of
// comma-separated names
// (first and last) and then
// returns an object where each
// firstname is a key, and each
// lastname is a value
//
// i.e. names("George Washington, John Adams, Kanye West")
// .. --> {
// George: "Washington",
// John: "Adams",
// Kanye: "West"
// }
function names(str) { var namesObj = {}; // separate names by ', ' var names = str.split(', '); // iterate on new array names.forEach( function( name ){ // split into first and last name var fullName = name.split(' '); // split into first and last names var first = fullName[0]; var last = fullName[1]; // add as key value pairs to an object namesObj[first] = last; }); // return new object return namesObj;
}
var results = names("George Washington, John Adams, Kanye West")
console.assert(results.George === "Washington")
console.assert(results['John'] === "Adams")
console.assert(results['Kanye'] === "West")
console.log(results);
Developer | Thomas Weld |
Username | thomasweld |
Uploaded | January 09, 2023 |
Rating | 3 |
Size | 1,944 Kb |
Views | 8,096 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Learnyounode BABY STEPS - es6 solution | 1,410 Kb |
Blue button | 1,562 Kb |
Fibonacci Sequence JavaScript | 1,421 Kb |
Check Prime Number JavaScript | 1,655 Kb |
IronNews | 2,067 Kb |
Staircase in JavaScript | 1,477 Kb |
Calculator - HTML, CSS, JavaScript | 4,658 Kb |
JavaScript Random Number Guessing Game | 1,636 Kb |
FizzBuzz | 1,594 Kb |
Palindrome Checker | 1,846 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Buttons with style | Chbymnky | 2,082 Kb |
Simple Login Form Template | Banunn | 3,571 Kb |
Myprofile | SoufianeAbid | 2,451 Kb |
Draggable directive | YahyaKacem | 2,277 Kb |
Slides-07-1 POSITION | Exhtml | 1,909 Kb |
CSS Grid Test | Ajaykarwal | 2,377 Kb |
Canvas stripes | Adrianparr | 1,948 Kb |
A Pen by Eka Risyana | Risyana | 3,705 Kb |
Contact | GanNichiHa | 2,514 Kb |
Single element checkbox | Ivijaygupta | 1,996 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!