A Bear's Face on Mars Blake Lively's New Role Recognizing a Stroke Data Privacy Day Easy Chocolate Cake Recipe Peacock Discount Dead Space Remake Mental Health Exercises
Want CNET to notify you of price drops and the latest stories?
No, thank you

Obama jumps in to Hour of Code event with a little JavaScript

In campaign to promote computer programming, the president tells kids: "Don't just consume, create." Later, at a White House-hosted event, he even learns to write a few lines of code himself.

President Obama sits down with middle-school students, including Adrianna Mitchell, at an Hour of Code event next to the White House. The event coincides with Computer Science Education Week. Andrew Harrer -- Pool/Getty Images

Anyone can learn to code -- even world leaders, who are not often thought of as the most tech-savvy bunch. The president of the US? Yep. The prime minister of the UK. Check.

To promote the idea that anyone can do it, President Obama sat down Monday with middle-school students at a White House-hosted event and learned to write a few lines of JavaScript.

The event was part of the second annual Hour of Code campaign, spearheaded by nonprofit Code.org, whose mission is to make computer science accessible to kids everywhere.

More than 77,000 Hour of Code events worldwide are scheduled for this week -- dubbed Computer Science Education Week -- at schools, public libraries and coding clubs, among others. Earlier today in London, students taught UK Prime Minister David Cameron a few things about programming.

In a video to champion Hour of Code events this week, Obama has a message for young people: "Don't just consume things, create things. Take an hour to learn more about the technology that touches every part of our lives."

Also this week, Code.org has lined up tech luminaries and celebrities -- from Bill Gates to Jessica Alba to Usher -- to participate in video chats on its YouTube channel with 100 classrooms across the US.

Apple is holding hour-long workshops -- think of them as a sort of Intro to Computer Science class -- Thursday at all 446 of Apple's retail locations. Other companies hosting Hour of Code events include Disney Interactive, Microsoft and Best Buy. Google, Target, Salesforce.com and about three dozen other companies are also encouraging staff to participate in Hour of Code employee programs.