Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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.


Auto Save

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.


                <script defer src=""></script>

<div x-data="app" x-cloak>
	<div x-show="intro">
			Welcome to the Marvel Guess the Decade game. In this game, I'll show you a random comic cover selected anywhere from 1950 to the 2020s. You need to guess the decade the comic was released. 
		<button @click="start">Get Started</button>
	<div x-show="!intro">
		<img x-show="imageSrc" :src="imageSrc" class="cover">
		<div x-show="!imageSrc">
			<p><i>Loading cover...</i></p>

		<div x-show="guessReady" class="buttonRow">
			<!-- hard coded for 1950 to 2020. todo: come back in 7 years -->
			<template x-for="i in 8">
				<button @click="guess(1950+((i-1)*10))"><span x-text="1950+((i-1)*10)"></span>s</button>
		<div x-show="resultReady">
			<strong x-text="msg"></strong> This cover is from <span x-text="cover.title"></span> in <span x-text="cover.year"></span>.
				<button @click="getImage">Guess Again</button>
			You have currently gotten <span x-text="right"></span> correct and <span x-text="wrong"></span> wrong.



                [x-cloak] { display: none !important; }

img.cover {
	width: 415px;
	height: 615px;
	object-fit: cover;
	object-position: top;
	display: block;
	margin: auto;

div.buttonRow {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: 10px;


                document.addEventListener('alpine:init', () => {'app', () => ({
		right: 0,
		wrong: 0,
		guessReady: false,
		resultReady: false,
		cover: { title:null, year:null },
		start() {
			this.intro = !this.intro;
		async getImage() {
			this.imageSrc = null;
			this.guessReady = false;
			this.resultReady = false;
			let coverReq = await fetch('');
			this.cover = await coverReq.json();
			// add .year based on date
			this.cover.year ='/').pop();
			So, I kept seeing comics with WILDLY different years and figured out we could use regex.
			I'm keeping the code above, just in case, but this code here should help.
		  let found = this.cover.title.match(/\(([1-2][0-9]{3})\) #/);
			if(found) {
				console.log(`changing year to ${found[1]}`);
				this.cover.year = found[1];
			this.imageSrc = this.cover.url;
			this.guessReady = true;
		guess(decade) {
			// so decade will come in as a base 4d year, like 2000, 
			// my year from the API is m/yyyy. so we can easily get y, 
			// and then simply check the first 3 digits
			console.log('right is', this.cover.year);
			if(decade.toString().substring(0,3) === this.cover.year.substring(0,3)) {
				this.msg = 'You got it right!';
			} else {
				this.msg = 'Sorry, you were wrong!';
			this.guessReady = false;
			this.resultReady = true;