Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Example</title>
</head>
<body>
	<h1 id="title">This is an example.</h1>
	<input type="checkbox">
	<button class="btn">Click me</button>

	<ul id="listId">
		<li class="list">
			<a href="https://www.google.com">Google</a>
		</li>
		<li class="list">mycoolwebsite</li>
		<li class="list">hackercollective</li>
	</ul>
	<script src="index.js"></script>
</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
// function short(str){
	// let split = str.split(" ")
	// let shortestWord = split.reduce((acc,currVal)=>acc.length<=currVal.length?acc:currVal)
	// let wordcount = shortestWord.length

// 	let split = str.split(" ")
// 	let shortestWord = split[0]

// 	for (let i = 1; i < split.length; i++){
// 		if (split[i].length<shortestWord.length){
// 			shortestWord = split[i]
// 		}
// 	}
// 	let wordcount = shortestWord.length
// 	console.log(shortestWord + " has the shortest wordcount of " + wordcount)
// }


// short("THC IS A COMMUNITY WITH COOL PPL")

function testXO(str){
	let split = str.split("")
	let xArray = []
	let oArray = []

	for (let i = 0 ; i < split.length; i++){
		if (split[i]=="x"||split[i]=="X"){
			xArray.push(split[i])
		}
		if (split[i]=="o"||split[i]=="O"){
			oArray.push(split[i])
		}
	}
	// console.log(xArray)
	// console.log(oArray)
	if (xArray.length == oArray.length){
		return true
	}
	return false
}

console.log(testXO("xxooo"))

function longestWord(str){
	let split = str.split(" ")
	let num = 0

	for (let i =0; i<split.length;i++){
		if (split[i].length>num){
			num = split[i].length
		}
	}
	return num
}

console.log(longestWord("THC IS AN AWEEEEESOME COMMUNITY"))


function endsWith(str,target){
	// return str.endsWith(target)
	// let targetLength = target.length
	// let newStr = ""
	// let split = str.split("")

	// for (let i = split.length-target.length; i<split.length; i++){
	// 	newStr+=split[i]
	// }
	// console.log(newStr)
	// console.log(newStr == target)
	// console.log(1==="1")
	console.log(str.slice(str.length - target.length) === target)
	console.log(str.slice(2,4))
}

endsWith("Open sesame", "same")

function deafGrandma(str){
	//loops
	// let sentence = str.split(" ")
	// console.log(sentence)
	// let newStr = ""
	// for (let i = 0; i < sentence.length; i++){
	// 	newStr += sentence[i].toUpperCase() + "!! "
	// }
	// console.log(newStr)

	//iteration methods
	// let sentence = str.split(" ")
	// let deaf = sentence.map(x=>{
	// 		return x.toUpperCase() + "!!"
	// })
	// console.log(deaf.join(" "))

	//hackish way - solve it in 2 lines!!
	let split = str.toUpperCase().split(" ").join("!! ")
	console.log(split+="!!")
}

deafGrandma("I have a bad feeling about this")
              
            
!
999px

Console