Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!DOCTYPE html>
<html lang="en">
		<title>Recreating Google Homepage</title>
		<link rel="stylesheet" href="assessmentSol.css" />
		<div class="container">
			<div class="logo">

			<div class="searchform">
				<input style="search" />

			<div class="buttons">
				<button>Google Search</button>
				<button>I'm Feeling Lucky</button>
				<p>Google offered in: <a href="#">Malay</a></p>



                .container {
	text-align: center;
	width: 100%;
	height: auto;
	padding-top: 130px;
	/* center it */
	margin: 0 auto;

.logo {
	margin-top: 200px;
	/* border: 1px solid red; */
input {
	width: 400px;
	height: 30px;
	margin-bottom: 15px;

a {
	text-decoration: none;
p {
	font-family: arial;
	font-size: 9pt;

.google-logo {
	width: 300px;

.buttons {
	margin-bottom: 60px;
button {
	background-color: #f2f2f2;
	border: none;
	padding: 10px;
	margin: 10px;
	color: lightslategray;
	font-weight: bold;
	font-family: arial;
	border-radius: 2px;

a:hover {
	text-decoration: underline;
button:hover {
	color: black;
	border: 1px solid lightgray;



// MCQ
// A
// B
// D
// A,B,C
// C
// A,B,C
// A
// A
// C
// B

// Reverse A String Using Loops.
// reverse('abcde') == 'edcba'
// reverse('hello') == 'olleh'
// reverse('Greetings from The Hacker Collective') == 'evitcelloC rekcaH ehT morf sgniteerG'

// function reverse(str){
//     let reversed = "";
//     for (let i = str.length-1; i >= 0; i--){
//         reversed += str[i];
//     }
//     console.log(reversed);
// }

// Same Back And Forth - Is a string the same backwards and forwards? Return true if it is, false if it is not.
// sameBackAndForth("abba") === true
// sameBackAndForth("abcdefg") === false
// function sameBackAndForth(str){
//   var strRev = str.split("").reverse().join("");

//   if (str === strRev){
//     console.log(true);
//   } else{
//     console.log(false);
//   }
// }

// Given an integer, return an integer that is the reverse ordering of numbers.
// reverseInt(15) === 51
// reverseInt(981) === 189
// reverseInt(500) === 5
// reverseInt(-15) === -51
// reverseInt(-90) === -9

// function reverseInt(n) {
//     const reversed = n
//       .toString()
//       .split('')
//       .reverse()
//       .join('');

//     return parseInt(reversed) * Math.sign(n);
//   }

// SumArr - Find the sum of all items in an array, using loops.
// sumArr([1,2,3,4,5]) == 15
// sumArr([1000,2000,44,55,22]) == 3121
// sumArr([123,456,789]) == 1368

function sumArr(arr) {
	let count = 0;

	for (let i = 0; i < arr.length; i++) {
		count = count + arr[i];
	return count;

// Angry Grandma - You will write a function that takes in a String. The function should return a new sentence where every word is yelled. A yelled word is when each word is all uppercase followed by 2 exclamation marks (!!)
// deafGrandma("I have a bad feeling about this") == "I!! HAVE!! A!! BAD!! FEELING!! ABOUT!! THIS!!"
function deafGrandma(str) {
	let split = str.toUpperCase().split(' ').join('!! ');
	return (split += '!!!!');

// What Is Missing - Find the missing letter in the passed letter range and return it. If all letters are present in the range, return undefined.
// whatIsMissing("abcdefghijklmnopqrstuvwxyz") == undefined
// whatIsMissing("bcdf") == 'e'
// whatIsMissing("abcdefghjklmno") == 'i'
function whatIsMissing(str) {
	for (var i = 0; i < str.length; i++) {
		// charcodeat converts the alphabets to the character code (numbers that represent the given alphabets)
		/* here u can find out the character code of each character, and looping through all of them tells you what is missing */
		/* if code of current character is not equal to first character + no of iteration
          hence character has been escaped */
		if (str.charCodeAt(i) !== str.charCodeAt(0) + i) {
			/* if current character has escaped one character find previous char and return */
			// fromcharcode converts chacracter code  it back to alphabet
			return String.fromCharCode(str.charCodeAt(i) - 1);
	return undefined;

// test here

// Do a swap on the sentence using the arguments provided and return the new sentence.

// First argument is the sentence to perform the search and replace on (sentence)
// Second argument is the word that you want to change (before)
// Third argument is what you will be changing the second argument with (after)
// Preserve the case of the first character in the original word when you are replacing it. For example if you mean to replace the word "Book" with the word "dog", it should be replaced as "Dog"
// Hint 1: Check first letter case. toUpperCase()
// Hint 2: Find the index where before is in the string. indexOf()
// Hint 3: .splice()
// Hint 4: Make it into arrays first. Easier to manipulate.
// swap("His name is Tom", "Tom", "john") == "His name is John".
// swap("Let us get back to more Coding", "Coding", "algorithms") == "Let us get back to more Algorithms".
// swap("This has a spellngi error", "spellngi", "spelling") == "This has a spelling error".

function swap(str, pre, post) {
	// Find index of pre
	var preIndex = str.indexOf(pre);
	// Check to see if the first letter is uppercase or not
	if (str[preIndex] === str[preIndex].toUpperCase()) {
		// Change the post word to be capitalized before we use it.
		post = post[0].toUpperCase() + post.slice(1);
	} else {
		// Change the post word to be uncapitalized before we use it.
		post = post[0].toLowerCase() + post.slice(1);
	// Now replace the original str with the edited one.
	str = str.replace(pre, post);

	return str;

console.log(swap('Let us get back to more Coding', 'Coding', 'algorithms'));