×

Obama becomes first US president to publicly code

President Barack Obama participates in an 'Hour of Code' event with middle-school students including Adrianna Mitchell in the Eisenhower Executive Office Building next to the White House in Washington, D.C.
Andrew Harrer | Bloomberg | Getty Images
President Barack Obama participates in an 'Hour of Code' event with middle-school students including Adrianna Mitchell in the Eisenhower Executive Office Building next to the White House in Washington, D.C.

President Barack Obama became the first occupant of the Oval Office to publicly write a line of code on Monday.

Kicking off Code.org's Hour of Code campaign and Computer Science Education Week from the White House, Obama wrote a single line of JavaScript.

Read MoreCashing in on the coding revolution

This is what the president wrote, according to Code.org CEO Hadi Partovi:

moveForward(100);

The code, which included a predefined function for a tutorial using characters from Disney's "Frozen," moved a figure 100 pixels.

According to Partovi, Obama "asked if he needs to type the F in upper-case, and he got the () and the ; right too, he was very precise and didn't make a typing mistake."

Read MoreThe job skills gap starts in high school

"We're starting too late when it comes to making sure that our young people are familiar, not just with how to play a video game, but how to create a video game, not just how to work a smartphone, but how to create the apps for a smartphone," Obama said at the event. "One of the great things about America is we invent and make stuff, not just use it."

Here's a video of Obama working with students on his code: