

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solved exercises from the codehs programming with javascript course. It covers various programming concepts, including functions, variables, input/output, and basic graphics. The exercises provide practical examples and solutions for students learning javascript programming.
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


3.3.4: Your Name and Hobby - function start(){ println("My name is Leo."); println("I like to hunt.");
}
3.4.4: Apples and Oranges - function start(){ var numApps = 20; println("Number of Apples: " + numApps);
var numOra = 15; println("Number of Oranges: " + numOra);
var numOrg = 0; println("Number of Apples: " + numApps);
println("Number of Apples: " + numOra); }
3.5.4: Obi-Wan Says - function start(){ var name = readLine("YourName? "); var age = readInt("How many driods do you want to met?"); var wookies = readInt("How many wookies? "); println("Hi " + name + " you want to meet " + age + " droids and " + wookies + " Wookie."); }
3.6.6: Sporting Goods Shop - function start(){ var COST_OF_FRISBEE = 15; var amount = readInt("How many would like?"); var sum = COST_OF_FRISBEE * amount; println(sum);
}
3.6.7: Running Speed - function start(){ var miles = readInt(" How far did you run? "); var minutes = readInt("How many minutes"); var hours = minutes / 60;
var speed = miles/ hours; println("Speed in mph: " +speed);
3.7.7: French Flag - function start(){ var rectWidth = getWidth() / 3; var rectHeight = getHeight();
var blueRect = new Rectangle(rectWidth, rectHeight); blueRect.setPosition(0, 0); blueRect.setColor(Color.blue); add(blueRect);
var redRect = new Rectangle(rectWidth, rectHeight); redRect.setPosition(rectWidth * 2, 0); redRect.setColor(Color.red); add(redRect); }
3.7.8: Snowman - var BOTTOM_RADIUS = 100; var MID_RADIUS = 60; var TOP_RADIUS = 30;
function start(){ var circle = new Circle(30); circle.setPosition(200, 130); circle.setColor(Color.grey); add(circle);
var circle = new Circle(60); circle.setPosition(200, 220); circle.setColor(Color.grey); add(circle);
var circle = new Circle(100); circle.setPosition(200, 380); circle.setColor(Color.grey); add(circle); }